proxe
January 20, 2013, 11:05pm
1
I am trying to get a sublist(?) item from a list for a report in a operator
such as: self.report ({‘INFO’}, “this is a report about ‘%s’” % self.list
this works great but I am actually trying to get the second item in a list such as:
list = EnumProperty(items=[(1,2,3),(a,b,c),(x,y,z)])
how would I go about getting the second value (2 or b or y) in the report example above?
CoDEmanX
(CoDEmanX)
January 21, 2013, 7:09am
2
EnumProperty expects triplets for the items parameter:
http://www.blender.org/documentation/blender_python_api_2_65_8/bpy.props.html#bpy.props.EnumProperty
like
bpy.types.Scene.my_list = bpy.props.EnumProperty(name="My List", items = (('1', 'First', 'Description one'), ('2', 'Second', 'Description two'), ('3', 'Third', 'Description three')))
if you wanted to know what items are in the enumprop, you could access them like:
bpy.types.Scene.my_list[1]['items'][1][1]
# output: 'Second'
but usually that enumprop is added to a panel - layout.prop(…)
and you wanna know what entry is active / was selected by the user:
bpy.context.scene.my_list
# output: '1'
The identifier of the selected item entry is returned
proxe
January 21, 2013, 10:38am
3
Im actually using the identifier for the operator as a shortcut to accessing some items in blenders api based on context, but they are not exactly easy on the eye for the report. More specifically I’m using the enumprop in a panel AND to define its application in the operator, I suppose I could always just assign a list for both to the same effect.
proxe
February 2, 2013, 7:49pm
4
lists, inside lists, inside lists, , oh ya.