I want to store default export settings in addon preferences. Something like this:
class MyAddonPreferences(bpy.types.AddonPreferences):
bl_idname = __name__
my_saved_prop: BoolProperty()
def draw(self, context):
self.layout.prop(self, "my_saved_prop")
class MyExportOperator(bpy.types.Operator, ExportHelper):
<...>
prefs = bpy.context.preferences.addons[__name__].preferences
my_export_option: BoolProperty(default = prefs.my_saved_prop)
# AttributeError: 'NoneType' object has no attribute 'my_saved_prop'
But I can't access the stored settings from the helper's attributes, only from its functions. I can populate the settings in invoke():
def invoke(self, context, event):
prefs = bpy.context.preferences.addons[__name__].preferences
self.my_export_option = prefs.my_saved_prop
return ExportHelper.invoke(self, context, event)
...But that will mean any non-default settings from previous calls will be lost. Is there any way around this?