enum list how to work with theses?

exampel of enum list

menu1 = EnumProperty(items=(
(‘1’, ‘First Graph’, ‘The first item’),
(‘2’, ‘Second Curve’, ‘The second item’),
(‘3’, ‘Third Graph’, ‘The third item’),
(‘4’, ‘Fourth graph’, ‘The 4 item’)
))

is there a way to add each item otherwise then this?
i mean one element at a time for instance?

i like to transfert for instance from a list of items to this enumlist but now?

and ounce the enum list is done is there a way to read the different items on each row of the enum list ?

Thanks

One way:

mylist = [('1', 'First Graph', 'The first item'),
('2', 'Second Curve', 'The second item'),
('3', 'Third Graph', 'The third item'),
('4', 'Fourth graph', 'The 4 item')]

menu1 = EnumProperty(items=mylist, name='Menu1')

I don’t know how to read from the rows in the enum list, but you you could make it refer back to the original list:

scene = bpy.context.scene
n = scene['menu1'] #the index of the menu choice
item1 = mylist[n][0] #would give you the first item in that row
item2 = mylist[n][1] #would give you the second item in that row
item3 = mylist[n][2] #would give you the third item in that row

Again, probably not the best way, but it works. :slight_smile:

ok for reading

but i would like to be able to load up this from an array
so anyway to laod one row at a time may be and how ?

don’t know like opposite of reading may be
mylist[n][2]=item3

iis that possible?

cause i need to make a menu which is function of another menu
so for each first menu item there will be a different second menu
sort of a dynamic menu function of the first menu items

hope it makes sense here!

otherwise i would have to define as many enumpropr for each first menu’s item
like the first opne has 7 different items
so i would have to define 7 different enumproperties for the second menu
and with a if loop select and assign the proper enumprop to the second menu

i hope there is a better way of doing this!

happy 2.5

i tried to add this to my little script and had to defined it at scene leve but get an error for defining the scene enumproper

menulist1 = [
(‘1’, ‘First Graph’, ‘The first item’),
(‘2’, ‘Second Curve’, ‘The second item’),
(‘3’, ‘Third Graph’, ‘The third item’),
(‘4’, ‘Fourth graph’, ‘The 4 item’)
]

iesmenu1 = bpy.types.Scene.EnumProperty(items=menulist1, name=‘Menu1’)

print (’ menu1 =’,menulist1 )

error is that it has not atribute enumproperty!

what’s wrong for defining this enum proper at scene level ?

Thanks

another good question here

when do you use scene defined properties
and the operators ones
http://www.blender.org/documentation/250PythonDoc/bpy.props.html?highlight=properties
cause in my case the panel is using operator for the menu!

so how do you define a scene operator propertie enum?

i tried with
iesmenu1 = bpy.props.EnumProperty(items=menulist1, name=‘Menu1’)

and seem to see it at main level but not going to the operator yet !

so i guess here u have to define theses enum as operator properties not as simple properties!

Thanks