Skip to main content
deleted 10 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferencespreferences = context.user_preferencespreferences
    addon_prefs = user_preferencespreferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    preferences = context.preferences
    addon_prefs = preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder
API link
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

Set it once in the addons User Preferences.

Suggest using a property in addon preferencesaddon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder
added 140 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder

Set it once in the addons User Preferences.

Suggest using a property in addon preferences The user chooses the folder. I had deleted this answer, as it is not "automatic", however setting a storage location once, is IMO, not a huge overhead.

Modify the script in link with a folder property

class ExampleAddonPreferences(AddonPreferences):
    # this must match the addon name, use '__package__'
    # when defining this in a submodule of a python package.
    bl_idname = __name__

    assets_folder = StringProperty(
            name="Assets Folder",
            subtype='DIR_PATH',
            )

    def draw(self, context):
        layout = self.layout
        layout.label(text="This is a preferences view for our addon")
        layout.prop(self, "assets_folder")

enter image description here

And then when you need to access it

    user_preferences = context.user_preferences
    addon_prefs = user_preferences.addons[__name__].preferences

    assets_folder = addon_prefs.assets_folder
added 125 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading
Post Undeleted by batFINGER
deleted 57 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading
Post Deleted by batFINGER
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading