Just linking the ticket number for issue #2671 to this forum thread.eivindkvedalen wrote:Ok, the offset value should then have units attached to it (at least) in the GUI. Could you please register this in the bug tracker?Syranolic wrote:Yes, I see that if the object property is normally displayed as "0,00 mm", for example, then it works.
But for the value of an offset, it doesn't. I don't many features, this is the only case I found...
Eivind
Spreadsheet and sketch parameters: incompatible units for + operator
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: Spreadsheet and sketch parameters: incompatible units for + operator
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Posts: 19
- Joined: Wed May 10, 2017 8:12 pm
Re: Spreadsheet and sketch parameters: incompatible units for + operator
Hi, not sure, but I think I found this same/similar problem.
1- I've created a spreadsheet, added some value with alias (val1_mm). The value has no unit, but the display unit is mm.
2- Added a Contraints.contraint1 (in mm).
3- Added a second constraint using the expression "Contraints.contraint1 + Spreadsheet.var1_mm", got the error "Incompatible unit for + operator".
4- Added units to the value, in the spreadsheet and the no error.
5- If using operator "*", the inverse happens. No error when there is no unit, and there is an error "Incompatible unit for * operator" when there is a unit in the spreadsheet value.
Note: Plese check attached example file, from which the images were taken.
multiplying by (1 mm) like stated below did solved the problem, its documented in:
1- https://www.freecadweb.org/wiki/Spreadsheet_Workbench; and
2- https://www.freecadweb.org/wiki/Manual: ... readsheets.
If using values from the spreasheet it works, they are unit compatible in the example I've used, which makes sense, thought might become difficult to understand in complex expressions. Note none of them has units in this example, the var1_mm has no units neither var2.
I would suggest documentation improvement, stating these examples an solution.
OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11580 (Git)
Build type: None
Branch: master
Hash: aa07c777453258edf9fed304cf82bcfeb8bdea95
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
1- I've created a spreadsheet, added some value with alias (val1_mm). The value has no unit, but the display unit is mm.
2- Added a Contraints.contraint1 (in mm).
3- Added a second constraint using the expression "Contraints.contraint1 + Spreadsheet.var1_mm", got the error "Incompatible unit for + operator".
4- Added units to the value, in the spreadsheet and the no error.
5- If using operator "*", the inverse happens. No error when there is no unit, and there is an error "Incompatible unit for * operator" when there is a unit in the spreadsheet value.
Note: Plese check attached example file, from which the images were taken.
multiplying by (1 mm) like stated below did solved the problem, its documented in:
1- https://www.freecadweb.org/wiki/Spreadsheet_Workbench; and
2- https://www.freecadweb.org/wiki/Manual: ... readsheets.
If using values from the spreasheet it works, they are unit compatible in the example I've used, which makes sense, thought might become difficult to understand in complex expressions. Note none of them has units in this example, the var1_mm has no units neither var2.
I would suggest documentation improvement, stating these examples an solution.
OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11580 (Git)
Build type: None
Branch: master
Hash: aa07c777453258edf9fed304cf82bcfeb8bdea95
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
- Attachments
-
- error_expression_incompatible_units_expr_sketch.fcstd
- (3.95 KiB) Downloaded 55 times
-
- Posts: 602
- Joined: Tue Jan 29, 2013 10:35 pm
Re: Spreadsheet and sketch parameters: incompatible units for + operator
It's not the same problem; you are mixing calculations with and without units, that's why you get these results; see below.mario.silva.costa wrote: ↑Wed Jul 19, 2017 8:40 am Hi, not sure, but I think I found this same/similar problem.
This means that the value entered does not have a unit attached to it; the display unit is only for presentation (and possibly do visual unit conversion), but does not affect the underlying representation.mario.silva.costa wrote: ↑Wed Jul 19, 2017 8:40 am 1- I've created a spreadsheet, added some value with alias (val1_mm). The value has no unit, but the display unit is mm.
This value gets a unit attached (length in mm).
Here you try to add one number with a unit and another one without. That is not allowed; the units have to match. It's maybe easier to understand if you had two numbers with units, like mm and kg. Adding a length and a mass doesn't make much sense, right?mario.silva.costa wrote: ↑Wed Jul 19, 2017 8:40 am 3- Added a second constraint using the expression "Contraints.contraint1 + Spreadsheet.var1_mm", got the error "Incompatible unit for + operator".
Here the two numbers have the same units, and are thus compatible.mario.silva.costa wrote: ↑Wed Jul 19, 2017 8:40 am 4- Added units to the value, in the spreadsheet and the no error.
When you multiply, you also multiply the unit. If you have a number with unit, say 20mm, and one without, like 3, then 3 * 20mm = 60mm. If you have two numbers with unit, say 20mm and 3mm, then 20mm*3mm= 60mm^2. This is an area (mm^2), and thus cannot be used as a length constraint. However, on my not-so-recent 0.16 version I'm testing on, I don't get these expected results, but I'm not able to recreate your error message either.mario.silva.costa wrote: ↑Wed Jul 19, 2017 8:40 am 5- If using operator "*", the inverse happens. No error when there is no unit, and there is an error "Incompatible unit for * operator" when there is a unit in the spreadsheet value.
To conclude, units works mostly as expected in FreeCAD, but because this has been added lately not all parts of FreeCAD handle them good enough at the moment. This is why I suggested the thread starter to register it in the tracker, so it can be fixed when time allows.
Eivind
-
- Posts: 19
- Joined: Wed May 10, 2017 8:12 pm
Re: Spreadsheet and sketch parameters: incompatible units for + operator
Hi Eivind,
First, thanks for your reply. After researching, and reading the post properly I've came to understand it. So, the only thing I might "complain" would be some documentation improvement or some application hint in the case of error.
Let me know if I can help with documentation ...
Anyway for me it is now clear, and I'll know how to deal with it in the future.
Cheers,
mc
First, thanks for your reply. After researching, and reading the post properly I've came to understand it. So, the only thing I might "complain" would be some documentation improvement or some application hint in the case of error.
Let me know if I can help with documentation ...
Anyway for me it is now clear, and I'll know how to deal with it in the future.
Cheers,
mc
Re: Spreadsheet and sketch parameters: incompatible units for + operator
@eivindkvedalen submitted PR#894 as a fix for issue #2671.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Spreadsheet and sketch parameters: incompatible units for + operator
@Syranolic please change forum thread title to: "[Solved] Ticket #2671 - Spreadsheet and sketch parameters: incompatible units for + operator" Thanks!Syranolic wrote:ping
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Spreadsheet and sketch parameters: incompatible units for + operator
Thanks for this solution
ulrich1a wrote: ↑Fri Aug 12, 2016 5:16 pm There is one point to say. The FreeCAD spreadsheet is different to other spreadsheets. It is not enough to put mm in the displayed unit, to make it a value with the length property attached. You have to explicitly put in the value with the unit. Or if it is just a number coming from some calculation, then you have to multiply it with "1 mm".
Ulrich