I have a multi file Addon where I want to set a default value for uv layers in the Addon preferences, while being able to choose a specific layout per file.
I set my preferences and make sure they get registered/unregistered:
class MY_AddonPreferences(AddonPreferences):
bl_idname = __package__
default_uvmethod_0: EnumProperty(
items=[
('SWATCH', '', ''),
('LIGHTMAP', '','')
],
default = 'SWATCH')
I make sure I can change the addon preferences in an addon preferences menu and define my Pointer properties and make sure they get registered/unregistered
class MY_SceneProperties(PropertyGroup):
addon_pref = bpy.context.preferences.addons['MyAddon'].preferences
action_uvmethod_0: EnumProperty(
items=[
('SWATCH', '', ''),
('LIGHTMAP', '','')
],
default = addon_pref.default_uvmethod_0)
I have no issues setting up the panels with these properties, the only issue is that somehow the 'addon_prefs' are not able to find my addon preferences even though I make sure they get registered first, It gives me this error:
If someone could point me in the right direction here I would be eternally gratefull
bpy.context
at the time of registration, it's not initialized yet. 3- At the time of registration you can't callMY_SceneProperties.addon_pref
since you're calling it from within the class annotations definition. 4- Even if you could, you're callingaddon_pref
which doesn't look like the same asMY_SceneProperties.addon_pref
. I think you want to exploreget
andset
docs.blender.org/api/current/… $\endgroup$