According to this wiki page:
Here is some code I'm trying:A complete list of property attributes can be seen in the PropertyStandard C++ header file. For instance, if you want to allow the user to enter only a limited range of values (e.g. using PropertyIntegerConstraint), in Python you will assign a tuple containing not only the property value, but also the lower and upper limit as well as the stepsize, as below:
prop = (value, lower, upper, stepsize)
Code: Select all
class SomeObject:
def __init__(self, obj):
self.Type = 'SomeObject'
obj.Proxy = self
# Length property
obj.addProperty('App::PropertyLength', 'Length', 'Base', 'Length tooltip')
obj.Length = (300, 100, 1000, 1) # I want a length property that defaults to 300, and can be between 100 - 1000 with a step-size of 1.
Code: Select all
File "/home/g/Projects/ose-universal-axis-macro/universal_axis/universal_axis_model.py", line 26, in __init__
obj.Length = (300, 100, 1000, 1)
<type 'exceptions.AttributeError'>: Attribute (Name: Length) error: 'wrong type as quantity: tuple'
FreeCAD version information:
OS: Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Unknown
Branch: master
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Locale: English/UnitedStates (en_US)