Problem using expressions/functions

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!
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Problem using expressions/functions

Post by adrianinsaval »

MrGadget49 wrote: Tue Nov 29, 2022 10:36 pm If i used the expression 'trunc(2.395in) and it calculated the answer to be 2.00 inches (because the input units were inches) and then you opened it on your system with the defaults set to mm, it would convert 2.00 inches to 50.8mm. Which would be exactly what I intended.

What it's doing now, is converting 2.395in to 60.833mm and then truncating that to 60. I would get 2.3622 inches. On your system, you will get 60mm. It's not even what I intended on my system, so it would probably never get to your system.
But that can only work in the case where you are directly writing 2.395in in the expression, in which case you can simply write without unit and multiply by the desired unit. When you are referencing a property the expression never sees the inches, it directly gets the value in mm because the value is stored in mm too. I guess that's the misconception, we're not taking 2.395in and converting to mm before using in the expression, the value is already stored in mm and passed to the expression as is (remember it must give consistent results in any system) and only gets converted to inches in the GUI for you.
Post Reply