Translations:Create a FeaturePython object part I/66/en

From FreeCAD Documentation

.


Once the box is created (and you've checked to make sure it's been recomputed!), select the object and look at your properties.
You should note two things:

  • Three new properties (length, width, and height)
  • A new property group, Dimensions.


Note also how the properties have dimensions. Specifically, they take on the linear dimension of the units set in the user preferences (see Edit -> Preference... -> Units tab).

In fact, if you were paying attention when you were entering the code, you will have noticed that three separate values were entered for each dimension. The length was a floating-point value (10.0), the width was a string, specifying millimeters ('10 mm') and the height was a string specifying centimeters ('1 cm'). Yet, the property rendered all three values the same way: 10 mm. Specifically, a floating-point value is assumed to be in the current document units, and the string values are parsed according to the units specified, then converted to document units.

The nice thing about the App::PropertyLength type is that it's a 'unit' type - values are understood as having specific units. Therefore, whenever you create a property that uses linear dimensions, use