I have a custom enum property which defines the colour channels RGB, or RGBA depending on whether a flag in the addon preferences is enabled. Because the only way I could get this to work was to define the enum items dynamically using a function, I cannot set the default value of the enum. However, I'd really like to enable all the channels by default. Is there a way, and a sensible location in my addon's code that I can set the value of the enum after it has been registered and without requiring user interaction?
This is my EnumProperty:
active_channels = EnumProperty(
name="Active Channels",
options={'ENUM_FLAG'},
items=channel_items,
update=update_rgba,
)
This is the function I'm using to populate it:
def channel_items(self, context):
prefs = context.user_preferences.addons[__name__].preferences
if prefs.alpha_support:
return ((red_id, "R", ""), (green_id, "G", ""), (blue_id, "B", ""),(alpha_id, "A", ""))
return ((red_id, "R", ""), (green_id, "G", ""), (blue_id, "B", ""))
Is there some way I can set the value of the enum in the addon's Panel code or on registration?