Skip to content

Instantly share code, notes, and snippets.

@yorikvanhavre
Last active December 16, 2015 17:09
Show Gist options
  • Save yorikvanhavre/5468398 to your computer and use it in GitHub Desktop.
Save yorikvanhavre/5468398 to your computer and use it in GitHub Desktop.
very simple info-carrying object
# custom object definition
class MyCustomObject():
def __init__(self,obj):
obj.addProperty("App::PropertyStringList","CustomProps","Base", "A placeholder for custom properties")
obj.Proxy = self
def execute(self,obj):
pass
# create one in the current doc
myobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","MyObject")
MyCustomObject(myobj)
# set some properties
myobj.CustomProps = ["myValue","123","myOtherValue","456"]
# retrieve a value
if "myValue" in myobj.CustomProps:
idx = myobj.CustomProps.index("myValue") + 1
val = myobj.CustomProps[idx]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment