[bug?] dimension constraints accept unitless values as mm
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!
[bug?] dimension constraints accept unitless values as mm
As you can see here using an expression as a dimensional constraint value which uses unitless numbers is accepted as mm:
This could lead to problems when using spreadsheets. I found the folowing sequence that could create a problem:
1. Create sketch, draw rectangle, constraint it, pad.
2. Create spreadsheet, add cell value "2", alias cell
3. Create sketch001, carbon copy sketch, make all lines construction, draw rectangle, constraint relative to CC geometry by alias+0.5 (2+0.5=2.5) - constraints are accepted as 2.5mm
4. Pocket sketch001 with fixed length - Ok. 5. Try to change Pocket.Length=Pad.Length - spreadsheet.alias - non compatible units error. 6. Change spreadsheet.cell value to "2mm" to remedy - sketch001 constraints break - 2mm + 0.5 is wrong
7. Fix constraints to alias+0.5mm - all ok
8. Change cell to 2.5 (forget the mm) -> all is broken again
The assumption that when expression returns unitless number it should be treated as mm makes the user believe that all is ok when using unitless values in spreadsheets.
.This could lead to problems when using spreadsheets. I found the folowing sequence that could create a problem:
1. Create sketch, draw rectangle, constraint it, pad.
2. Create spreadsheet, add cell value "2", alias cell
3. Create sketch001, carbon copy sketch, make all lines construction, draw rectangle, constraint relative to CC geometry by alias+0.5 (2+0.5=2.5) - constraints are accepted as 2.5mm
4. Pocket sketch001 with fixed length - Ok. 5. Try to change Pocket.Length=Pad.Length - spreadsheet.alias - non compatible units error. 6. Change spreadsheet.cell value to "2mm" to remedy - sketch001 constraints break - 2mm + 0.5 is wrong
7. Fix constraints to alias+0.5mm - all ok
8. Change cell to 2.5 (forget the mm) -> all is broken again
The assumption that when expression returns unitless number it should be treated as mm makes the user believe that all is ok when using unitless values in spreadsheets.
- benjaminwharton
- Posts: 46
- Joined: Mon Feb 25, 2019 1:03 am
Re: [bug?] dimension constraints accept unitless values as mm
I'm not 100% sure but I think generally under the hood FreeCAD uses unitless dimensions and converts them automatically for display, and that would apply in this case. If anyone could clarify that'd be helpful.
Re: [bug?] dimension constraints accept unitless values as mm
Am I wrong if I say that your example design uses imperial units ? It may somewhat explain the issue.
I don't think that FC can use "unitless" values. It has to keep some consistency in its core.benjaminwharton wrote: ↑Thu Mar 07, 2019 3:35 pm I'm not 100% sure but I think generally under the hood FreeCAD uses unitless dimensions and converts them automatically for display, and that would apply in this case. If anyone could clarify that'd be helpful.
IIRC, core unit is mm, but really not sure of that.
Re: [bug?] dimension constraints accept unitless values as mm
That is not the case. It was in standart and I changed it to imperial to check if 10+12 will be interpreted as 22in which was not the case. As you can see both 10+12 and 10mm+12mm are calculated to 0.86614in which is 22mm.
Re: [bug?] dimension constraints accept unitless values as mm
@kisolre
Can you give better instructions for how to reproduce this?
I don't understand the following:
Can you give better instructions for how to reproduce this?
I don't understand the following:
Code: Select all
1. Create sketch, draw rectangle, constraint it, pad.
What constraints did you use?
I cannot enter a constraint of "(10 + 12)" -- it is initially taken as "(10 + 12) thou"
If I delete the "thou" it is taken as inches
If I enter it as "(10 + 12) mm" it is accepted incorrectly and displayed as 1"
Note space between ")" and "mm"
If I enter it as "(10 mm + 12 mm)" it is accepted incorrectly and displayed as 1"
Again, note spaces between number and "mm"
If I enter it as "(10mm + 12mm)" it is accepted correctly and displayed as 0.87"
The expression used to construct the constraint (10mm + 12mm) is discarded (lost) in all of the above cases;
only the result is kept, displayed as an inch value.
Once the sketch task is closed,
if I try to edit the data value for the constraint, I get an empty entry field with no expression, not even 0.87..."
2. Create spreadsheet, add cell value "2", alias cell
3. Create sketch001, carbon copy sketch, make all lines construction, draw rectangle, constraint relative to CC geometry by alias+0.5 (2+0.5=2.5) - constraints are accepted as 2.5mm
This is a lot of steps and it is unclear to me what you mean.
Please give detailed instructions. Is Sketch001 supposed to have only one rectangle on it, or two?
What do you mean by "constraint relative to CC geometry"? Do you mean an expression like "Sketch.Constraints.Ht + alias + 0.5"?
4. Pocket sketch001 with fixed length - Ok.
Re: [bug?] dimension constraints accept unitless values as mm
We will be making simple openbottom box with top thickness X mm and wall thickness X+0,5 mm. General box dimensions does not matter.
1. Create new body. Create Sketch at XY plane. Draw rectangle. Fully constraint sketch. How you do it does not matter as long as there are constraints to be Carbon Copied later. Pad sketch - length does not matter as long as it is bigger than X. 2. Create spreadsheet. Enter unitless value in cell A1 - "2" for example. Give cell A1 alias "X". 3. Create Sketch001 at XY plane. Carbon copy Sketch into Sketch001. This will add the outer rectangle with all constraints from Sketch. Make all edges construction. Draw rectangle inside rectangle from Sketch. Dimension edges of the new rectangle to be "spreadsheet.X+0.5" inside from the edges of the outer rectangle. 4. Pocket Sketch001 reversed (up). Length does not matter. Everything is Ok until now.
5. Try to make Pocket.Length = Pad.Length-Spreadsheet.X - "Incompatible units for + operator" -Pad.Length is in mm, X is unitless 6. Change Spreadsheet.X to "2mm" to remedy 5. Now Sketch001 is broken because its constraints try to add 0.5 to 2mm 7. Fix Sketch001 constraints by explicitly adding 0.5mm
8. Set Pocket.Length=Pad.Length-Spreadsheet.X - Ok
9. Change Spreadsheet.X to unitless 2.5 (as if forgetting that you need dimensions)- Sketch001 and Pocket are broken.
1. Create new body. Create Sketch at XY plane. Draw rectangle. Fully constraint sketch. How you do it does not matter as long as there are constraints to be Carbon Copied later. Pad sketch - length does not matter as long as it is bigger than X. 2. Create spreadsheet. Enter unitless value in cell A1 - "2" for example. Give cell A1 alias "X". 3. Create Sketch001 at XY plane. Carbon copy Sketch into Sketch001. This will add the outer rectangle with all constraints from Sketch. Make all edges construction. Draw rectangle inside rectangle from Sketch. Dimension edges of the new rectangle to be "spreadsheet.X+0.5" inside from the edges of the outer rectangle. 4. Pocket Sketch001 reversed (up). Length does not matter. Everything is Ok until now.
5. Try to make Pocket.Length = Pad.Length-Spreadsheet.X - "Incompatible units for + operator" -Pad.Length is in mm, X is unitless 6. Change Spreadsheet.X to "2mm" to remedy 5. Now Sketch001 is broken because its constraints try to add 0.5 to 2mm 7. Fix Sketch001 constraints by explicitly adding 0.5mm
8. Set Pocket.Length=Pad.Length-Spreadsheet.X - Ok
9. Change Spreadsheet.X to unitless 2.5 (as if forgetting that you need dimensions)- Sketch001 and Pocket are broken.
Re: [bug?] dimension constraints accept unitless values as mm
I can follow these steps, and I get the same results in the daily build of freecad. I found (like you) that setting those width constraints in Sketch001 to "Spreadsheet.X + 0.5 mm" worked around the problem.
Cheers
Craig
Cheers
Craig
Re: [bug?] dimension constraints accept unitless values as mm
Excellent, Thanks. Easy to reproduce with the last example.
Sounds like a bug to me, but I don't think I'm qualified to proclaim it as such.
However, I will document it.
Sounds like a bug to me, but I don't think I'm qualified to proclaim it as such.
However, I will document it.
Re: [bug?] dimension constraints accept unitless values as mm
I'm using FreeCad version .18 on Win 7 and 10 finding the same problem here with both OS. I can't get version .19 to load so I'm restricted to .18 at the moment. Anyone find a fix to the mm/inch imperial problem when using the spreadsheet in version .18 or has this been fixed in version .19? I've searched for install help with .19 but nothing has worked and I got frustrated so staying with .18 for now.