I am trying to specify an enum property within a class but it always fails when I register the class.
size = bpy.props.FloatProperty(name="size", description="The current size of this particle.")
display_type = bpy.props.EnumProperty(name="display_type", items=('NONE','POINT','LINE','ICON','RENDERED'), default='NONE')
alive_state = bpy.props.EnumProperty(name="alive_state", items=('DEAD','UNBORN','ALIVE','DYING'), default='DEAD')
NOTE: If I comment the EnumProperty lines of code the class does register. If I don’t register the class and leave the EnumProperty lines uncommented I do not get a syntax error.
I’m not sure why it does not work. Some kind of language barrier?
Aren’t you supposed to affect a list of three items tuples in the ‘items’ property of the enum ?
items = [(‘NONE’, “nothing”, “this is just nothing”), (‘POINT’, “single point”, "this is a point),…]
Maybe it would help.
Each list item is a tuple: identifier, name, description):
dTypes = [('NONE','NONE','NONE'),('POINT','POINT','POINT'),('LINE','LINE','LINE'),('ICON','ICON','ICON'),('RENDERED','RENDERED','RENDERED')]
display_type = bpy.props.EnumProperty(name='display_type', items=dTypes)
It looks like the items argument should be a list of tuples.
I usually make a function to do it:
return [(a,a,a,) for a in L]
display_type = bpy.props.EnumProperty(name="display_type", items=enumlist(['NONE','POINT','LINE','ICON','RENDERED']), default='NONE')
alive_state = bpy.props.EnumProperty(name="alive_state", items=enumlist(['DEAD','UNBORN','ALIVE','DYING']), default='DEAD')
The first item of the tuple is the value of the property, the second one is what will be displayed at the screen and the third one is a small description that appears in some help pop-ups. Is it a good idea to make those three items equal to each other ?
I think in my case it might be OK if they are all the same value. I don’t plan on displaying them. I was just trying to emulate the internal API in a class.