Std VarSet

Other languages:

Std VarSet

Menu location
None
Workbenches
All
Default shortcut
None
Introduced in version
1.0
See also
Spreadsheet Workbench, DynamicData Workbench

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

  1. Do one of the following:
  2. The Add a property dialog box opens.
  3. Enter a Name for the property.
    • The name must be unique for the VarSet.
    • Only alphanumeric characters and underscores (A to Z, a to z, 0 to 9 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.
  4. Enter a Group name for the property or select a group from the list. Group names have the same restrictions as property names.
  5. Select the property Type from the list. See below for the most common types.
  6. Enter a Value for the property. This input accepts units for properties that have units.
  7. Optionally check the Add another checkbox if you want to add more properties.
  8. Optionally enter a Tooltip for the property.
  9. Press the OK button.
  10. If the Add another checkbox has been checked, the dialog box reopens and a new property can be added.
  11. 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
App::PropertyAngle ° (or deg)
App::PropertyBool true or false, can be used in conditional expressions
App::PropertyDistance mm
App::PropertyFloat Decimal number
App::PropertyInteger Whole number
App::PropertyLength mm Similar to App::PropertyDistance but cannot be negative
App::PropertyString Text string

Notes

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()