[bug?] dimension constraints accept unitless values as mm

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
kisolre
Veteran
Posts: 4162
Joined: Wed Nov 21, 2018 1:13 pm

[bug?] dimension constraints accept unitless values as mm

Post by kisolre »

As you can see here using an expression as a dimensional constraint value which uses unitless numbers is accepted as mm:
Dimensionless constraint.JPG
Dimensionless constraint.JPG (133.52 KiB) Viewed 3690 times
.
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.
DimConstrUnitless.JPG
DimConstrUnitless.JPG (183.17 KiB) Viewed 3690 times
5. Try to change Pocket.Length=Pad.Length - spreadsheet.alias - non compatible units error.
DimConstrUnitlessErr.JPG
DimConstrUnitlessErr.JPG (119.56 KiB) Viewed 3690 times
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.
User avatar
benjaminwharton
Posts: 46
Joined: Mon Feb 25, 2019 1:03 am

Re: [bug?] dimension constraints accept unitless values as mm

Post by benjaminwharton »

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.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [bug?] dimension constraints accept unitless values as mm

Post by openBrain »

kisolre wrote: Thu Mar 07, 2019 2:02 pm 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.
Am I wrong if I say that your example design uses imperial units ? It may somewhat explain the issue.
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.
I don't think that FC can use "unitless" values. It has to keep some consistency in its core.
IIRC, core unit is mm, but really not sure of that.
kisolre
Veteran
Posts: 4162
Joined: Wed Nov 21, 2018 1:13 pm

Re: [bug?] dimension constraints accept unitless values as mm

Post by kisolre »

openBrain wrote: Thu Mar 07, 2019 7:59 pm Am I wrong if I say that your example design uses imperial units ? It may somewhat explain the issue.
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.
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [bug?] dimension constraints accept unitless values as mm

Post by NormandC »

openBrain wrote: Thu Mar 07, 2019 7:59 pm IIRC, core unit is mm
You are correct.
garya
Posts: 405
Joined: Tue Nov 20, 2018 1:00 am
Location: Ovando, MT, USA

Re: [bug?] dimension constraints accept unitless values as mm

Post by garya »

@kisolre

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.
kisolre
Veteran
Posts: 4162
Joined: Wed Nov 21, 2018 1:13 pm

Re: [bug?] dimension constraints accept unitless values as mm

Post by kisolre »

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.
Sketch.JPG
Sketch.JPG (102.34 KiB) Viewed 3585 times
2. Create spreadsheet. Enter unitless value in cell A1 - "2" for example. Give cell A1 alias "X".
Spreadsheet.JPG
Spreadsheet.JPG (59.73 KiB) Viewed 3585 times
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.
Sketch001.JPG
Sketch001.JPG (133.26 KiB) Viewed 3585 times
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
Pocket.Length.JPG
Pocket.Length.JPG (85.83 KiB) Viewed 3585 times
6. Change Spreadsheet.X to "2mm" to remedy 5. Now Sketch001 is broken because its constraints try to add 0.5 to 2mm
Sketch001.broken constraintsJPG.jpg
Sketch001.broken constraintsJPG.jpg (74.59 KiB) Viewed 3585 times
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.
User avatar
craig9
Posts: 20
Joined: Thu Mar 22, 2018 10:45 pm
Contact:

Re: [bug?] dimension constraints accept unitless values as mm

Post by craig9 »

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
garya
Posts: 405
Joined: Tue Nov 20, 2018 1:00 am
Location: Ovando, MT, USA

Re: [bug?] dimension constraints accept unitless values as mm

Post by garya »

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.
Bebop
Posts: 7
Joined: Sat Apr 02, 2016 6:57 am

Re: [bug?] dimension constraints accept unitless values as mm

Post by Bebop »

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.
Post Reply