GuiCommand: Name: Std VarSet Workbenches: All Version: 1.0 SeeAlso: Spreadsheet_Workbench, DynamicData_Workbench
Std VarSet
Description
The Std VarSet command creates a VarSet. A VarSet is a set of properties that can be used as variables in expressions.
The Add a property dialog box
Usage
- Do one of the following:
- To create a new VarSet: press the
Create a variable set button.
- To edit an existing VarSet: double-click the set in the Tree view.
- To create a new VarSet: press the
- The Add a property dialog box opens.
- Enter a Name for the property.
- The name must be unique for the VarSet.
- Only alphanumeric characters and underscores (
A
toZ
,a
toz
,0
to9
and_
) are allowed. - The first character may not be a digit.
- FreeCAD uses the UpperCamelCase convention for its property names, meaning each word starts with a capital letter, and there are no spaces or underscores. When the Property editor displays such a name, spaces are inserted between the words, making the name easier to read. It is advisable to follow this convention.
- Enter a Group name for the property or select a group from the list. Group names have the same restrictions as property names.
- Select the property Type from the list. See below for the most common types.
- Enter a Value for the property. This input accepts units for properties that have units.
- Optionally check the Add another checkbox if you want to add more properties.
- Optionally enter a Tooltip for the property.
- Press the OK button.
- If the Add another checkbox has been checked, the dialog box reopens and a new property can be added.
- Press the Cancel button when done.
Common property types
FreeCAD supports many property types. The table below lists some of the most common types. See FeaturePython Custom Properties for more information.
++++
| Property type | Default unit (if any) | Remark |
+==================================+=======================+======================================================================================================================+
| | ° (or deg) | |
| {{Incode|App::PropertyAngle}} | | |
| | | |
++++
| | | |
| {{Incode|App::PropertyBool}} | | True
|
| | | |
| | | or False
, can be used in conditional expressions |
++++
| | mm | |
| {{Incode|App::PropertyDistance}} | | |
| | | |
++++
| | | Decimal number |
| {{Incode|App::PropertyFloat}} | | |
| | | |
++++
| | | Whole number |
| {{Incode|App::PropertyInteger}} | | |
| | | |
++++
| | mm | Similar to {{Incode|App::PropertyDistance}} but cannot be negative |
| {{Incode|App::PropertyLength}} | | |
| | | |
++++
| | | Text string |
| {{Incode|App::PropertyString}} | | |
| | | |
++++
Notes
- Properties can also be added to existing VarSets in the Expression editor by checking the Show variable sets checkbox.
- A property can be removed from a VarSet via the context menu of the Property editor.
- A group name can be changed via the same menu.
- The command currently cannot set the list of allowed items of an {{Incode|App::PropertyEnumeration}} property. This can be done via Python code or in the Property editor. The steps for the latter option are:
- Select Show hidden in the context menu of the Property editor.
- Expand the node of the property.
- Click in the Enum field.
- Press the ... button that appears.
- Enter values in the List dialog box that opens.
- Press the OK button.
Scripting
import FreeCAD as App
doc = App.ActiveDocument
var_set = doc.addObject("App::VarSet", "VarSetName")
var_set.addProperty("App::PropertyInteger", "MyNumber") # Property is added to the Base group.
var_set.MyNumber = 123
var_set.addProperty("App::PropertyString", "MyText", group="SomeGroup", doc="Some tooltip information")
var_set.MyText = "Abc"
doc.recompute()
⏵ documentation index > Std VarSet
This page is retrieved from https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Std_VarSet.md