Last active
December 16, 2015 17:09
-
-
Save yorikvanhavre/5468398 to your computer and use it in GitHub Desktop.
very simple info-carrying object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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