# How can I set a default value on a Dynamic EnumProperty?

I am trying to fix a bug in the Animation Nodes addon.

The loop nodes has a dynamic EnumProperty and I need to select a default value. But only when the EnumProperty contains Items.

For that I need to know what the value of default is when I don't give it a value. I thought it was an empty string

selectedLoop = bpy.props.EnumProperty(
items=getStartLoopNodeItems,
name="Selected Loop",
default="",
update=updateActiveL)


but this does not have the same behaviour as if I left out the default parameter

selectedLoop = bpy.props.EnumProperty(
items=getStartLoopNodeItems,
name="Selected Loop",
update=updateActiveL)


Does anyone know what I have to pass to default in order to have the same behaviour?

EDIT: I discovered that when I add the default parameter the EnumProperty is not created apparently because when I try to add it to the layout later it gives me this error:

rna_uiItemR: property not found: mn_LoopCallerNode.selectedLoop

• is it just None ? – Chebhou Feb 27 '15 at 19:24
• I just tried that after posting my question, but it doesn't seem to work either – Mathieu David Feb 27 '15 at 19:25
• it could be "NONE" as the getStartLoopNodeItems() will add this if it's empty – Chebhou Feb 27 '15 at 19:51
• Tried but got the same result again. – Mathieu David Feb 27 '15 at 20:04
• items[0][0] if that is acceptable, or you can force the getStartLoopNoodeItems() to add the empty item in any case and put it as default – Chebhou Feb 27 '15 at 20:04

There is no default when items is a function (you'll get an error if you try to specify it).
Note even with 'static' enums, not specifying the default is not the same as giving "" or None, currently. Not very pythonic, but a consequence of our current C <-> python code.
• Eh, well, not really… This would have to be a callback too, way overkill imho. Note however that, since, when no default is specified, item with '0' value is used, you are kind of able to control what's default item from items function. – mont29 Feb 28 '15 at 10:41