Draft.string from a parameters (or expression)

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
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft.string from a parameters (or expression)

Post by Roy_043 »

dimitar wrote: Mon Jan 24, 2022 9:35 am mach the scene units
FreeCAD does not have this concept. Internally it always works in mm.

Modified example to show dimensions in m:
list(<<Cube length: %sm>> % (Box.Length/1000mm); <<Cube width: %sm>> % (Box.Width/1000mm); <<Cube height: %sm>> % (Box.Height/1000mm))
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Draft.string from a parameters (or expression)

Post by yorik »

When these tools were created, the expression engine was much simpler and couldn't do these things like automatic conversion of numbers into text.

There is still improvement to be done though. Maybe a cool thing we could do is to add a couple of properties to Draft texts, to handle such cases when it's used to display numeric result? For example: a "unit" property. If set, all numeric values found in the text string will be converted to that unit. However, there is no way for the Text object to know the base unit. So maybe a "factor" unit instead, that would just perform a multiplication?

Not sure if that is really useful, maybe it's better to do the factoring directly inside the expression, like @Roy_043 suggests... To kind of force users to know what they're doing?
Post Reply