Other Parts Of EnumProperty?

Hello All,

I have defined and EnumProperty in the preferences for my AddOn.


    render_type = bpy.props.EnumProperty(name="Render Type",
        items=[
            ('PIXIE', 'Pixie Render Engine', 'Pixie~rndr~texmake~sdrc~sdrinfo~.sdr~'),
            ('3DELIGHT', '3Delight Render Engine', '3Delight~renderdl~tdlmake~shaderdl~shaderinfo~.sdl~-t'),
            ('RENDERMAN', 'Renderman Render Engine', 'Renderman~@~@~@~@~@~@')],
            default='3DELIGHT', update=updatePreferences)   

Each item is made up of three parts. How do I get access to the other data?

In my updatePreferences if I reference render_type I just get a string, not a list.


def updatePreferences(self,context):
    # At this point render_type is just a string?
    print("updateBlendshadePreferences: %s" % self.render_type)

An Enumeration actually is meant for named constants. (0 = “Orange”, 1 = “Apple”, 2 = “Banana”, …) . Blender stores integers internally for enumeration props and saves them to the blend.

The name, description and icon are passed for the GUI.

You can access the items via


    #YourAddonPreferences subtype of bpy.types.AddonPreferences and has been registered

    items = bpy.types.YourAddonPreferences.render_type[1]['items']

For a list type use bpy.props.CollectionProperty.

Thanks for the clue, but I still get an error.
“Type Error: String indicies must be integers”.

So I think preferences may not be working correctly. It always presents a string. [1]['items] is invalid on a string.

For a list type use bpy.props.CollectionProperty.

Preferences does not seem to support CollectionProperties at this time that is why I am trying to cram a bunch of data into a delimited string.

Which I do have working in this form.


    render_type = bpy.props.EnumProperty(name="Render Type",
        items=[
            ('Pixie~rndr~texmake~sdrc~sdrinfo~.sdr~', 'Pixie Render Engine', 'PIXIE'),
            ('3Delight~renderdl~tdlmake~shaderdl~shaderinfo~.sdl~-t', '3Delight Render Engine', '3DELIGHT'),
            ('Renderman~@~@~@~@~@~@', 'Renderman Render Engine', 'RENDERMAN')],
            default='3Delight~renderdl~tdlmake~shaderdl~shaderinfo~.sdl~-t', update=updatePreferences) 

Put your delimited list elements in the first field and then you can access them directly. The second field will appear in the AddOns UI preferences panel. The 3rd value is not accessible at this time (AFAIK).

Test it in the console. The result looks like this for me:
http://www.pasteall.org/pic/show.php?id=74696

Hmm…

I get a different result typing in the same thing using Blender 2.71 official.

Attachments


It depends of where you need to access them. If is in the preferences file you can access the item array if you just define in a scope where the updatePrefrences function can reach it.
You can also access them through RNA Type etc. In the updatePreferences function is is a update= callback you can do this access it


print(self.rna_type.render_type[1]['items'])

also note that you don’t have the operator he is showing you as an example.

Thanks Linusy, that worked inside my updatePreferences!