I'm working on a plugin modification which is a tool for exporting gltf. On the export windows, we have a choice to put "Copyright" & "Default Texture Location" parameters as you can see here :

enter image description here

I wanted to add some input into the preferences tab of the addon by adding two input :

  • Default Texture Location
  • Default Copyright Name

That way, we could just set this one time and no need to make some operator presets etc.. enter image description here

My code is for the preference part is :

## class to add the preference settings
class addSettingsPanel(bpy.types.AddonPreferences):
    bl_idname = __package__
    settings_default_texture_location: bpy.props.StringProperty (
        name = "Default Texture Location",
        description = "Default Texture Location",
        default = "../texture"


    settings_default_copyright: bpy.props.StringProperty (
        name = "Default Copyright Name",
        description = "Default Copyright Name",
        default = ""

    ##bpy.types.Scene.toto = settings_default_copyright

   ## bpy.types.Scene.my_sel_value = bpy.props.StringProperty(name="Sel")

    ## draw the panel in the addon preferences
    def draw(self, context):
        layout = self.layout
        box = layout.box()

        ##row = layout.row()
        col = box.column(align = True)

        ## texture default location
        col.prop(self, 'settings_default_texture_location', expand=True)

        ## default copyright
        col.prop(self, 'settings_default_copyright', expand=True)

The question is :

How to access to these values in the export windows, which is on another file to show it in the first image instead of the blank label "Textures" and "Copyright" ?


As @brockmann Suggested in the comments,

I modified the code to :

preferences = bpy.context.preferences
addon_prefs = preferences.addons[__package__].preferences

export_copyright: StringProperty(
    description='Legal rights and conditions for the model',

But I've got the error " KeyError: ... key "Blender2MSFS.exporter" not found. So I tried to manually put "Blender2MSFS" instead of package and it is not working too.

The code is here : https://github.com/btronquo/Blender2MSFS2 exporter/init.py (line 96,97 and then 129 / 151)

  • $\begingroup$ Hello, could you also post the code that's responsible for drawing the UI showed in the 1st screenshot ? $\endgroup$
    – Gorgious
    Commented Oct 29, 2021 at 8:05
  • $\begingroup$ Open up __init__.py in the export folder, declare your preferences there and assign the new properties to the default parm of e.g. export_copyright (line 122). $\endgroup$
    – brockmann
    Commented Oct 29, 2021 at 8:05
  • $\begingroup$ @Gorgious I guess the OP is talking about this add-on and wants to modify it. I guess... :) $\endgroup$
    – brockmann
    Commented Oct 29, 2021 at 8:07
  • $\begingroup$ @brockmann, I don't understand How i'm supposed to retrive the value and put it in the default="" place ? `` export_copyright: StringProperty( name='Copyright', description='Legal rights and conditions for the model', default='' )`` It would be : default=settings_default_copyright.default or something ? $\endgroup$
    – Boris
    Commented Oct 29, 2021 at 8:22
  • $\begingroup$ Pretty straight forward, see the demo in the docs. You can get a reference to the prefs via addon_prefs = preferences.addons[__name__].preferences and then just assign it (default=addon_prefs.default_texture_location) as mentioned. $\endgroup$
    – brockmann
    Commented Oct 29, 2021 at 8:27

1 Answer 1


In the menu.

Could simply set these values in the menu function, which is how most users will invoke the operator (filebrowser). This will "fill in" the exporter properties with those set in the addon prefs.

Note have simply named same as exporter prop, eg export_texture_dir rather than the "long winded" settings_default_texture_location

exporter/__init__.py circa line 962

def menu_func_export(self, context):
    # get the addon name
    name = __name__.split(".")[0]
    preferences = context.preferences.addons.get(name)
    op = self.layout.operator(ExportExtendedGLTF2.bl_idname, text='extended glTF 2.0 (.glb/.gltf) for MSFS')
    if preferences:
        addon_prefs = preferences.preferences
        op.export_copyright = addon_prefs.export_copyright
        op.export_texture_dir = addon_prefs.export_texture_dir

How do I change the default settings of export operators?

Alternatively could do same in the operators invoke method.

  • $\begingroup$ Awesome, I was so focused on the field them self that I have missed the menu function A BIG THANK YOU ! $\endgroup$
    – Boris
    Commented Oct 29, 2021 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .