diff --git a/README.md b/README.md index 6996b5a..16c0687 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ Modifications: - Additional export **Zip pack - keep hierarchy** Standard Bat pack is doing an "assembly", modifying file internal links. This zip pack leave the file untouched. Behavior description: - The root folder for zipping use the environment variable `ZIP_ROOT` (accessed with `os.getenv('ZIP_ROOT')` if defined). - - If there is no such env variable, it fallback to path specified in addon preferences. + - if `ZIP_ROOT` is not defined, use `PROJECT_ROOT` variable. + - If there is no such env variables, it fallback to path specified in addon preferences. + - A checkbox allow to avoid the replacement of root properties with env variables. - In the export browser window settings (sidebar), user can choose the packing root folder, prefilled by env or addon preference path - If nothing specified, root will be automatically defined with the most upper folder covering the whole dependancies hierarchy. @@ -16,6 +18,11 @@ Standard Bat pack is doing an "assembly", modifying file internal links. This zi ### Changelog +1.3.4 + +- added: `PROJECT_ROOT` key is used if `ZIP_ROOT` is not specified. Fallback to initial property if neither exists +- added: checkbox to disable env variable check + 1.3.3 - code: sys.module name corrected when addon folder isn't named `blender_asset_tracer` as expected diff --git a/__init__.py b/__init__.py index d7f460f..7d89f0d 100644 --- a/__init__.py +++ b/__init__.py @@ -21,11 +21,12 @@ # __version__ = '1.3' +# branched from source BAT since 1.3.0 bl_info = { "name": "Blender Asset Tracer", "author": "Campbell Barton, Sybren A. Stüvel, Loïc Charrière and Clément Ducarteron", - "version": (1, 3, 3), + "version": (1, 3, 4), "blender": (2, 80, 0), "location": "File > External Data > BAT", "description": "Utility for packing blend files", @@ -264,10 +265,19 @@ def menu_func(self, context): layout.separator() layout.operator(ExportBatPack.bl_idname) filepath = layout.operator(BAT_OT_export_zip.bl_idname) - root_dir_env = os.getenv('ZIP_ROOT') - if not root_dir_env: # if no env use prefs instead - root_dir_env = preferences.get_addon_prefs().root_default - filepath.root_dir = '' if root_dir_env == None else root_dir_env #os.getenv('PROJECT_STORE') + + prefs = preferences.get_addon_prefs() + + root_dir_env = None + if prefs.use_env_root: + root_dir_env = os.getenv('ZIP_ROOT') + if not root_dir_env: # first fallback to PROJECT_ROOT + root_dir_env = os.getenv('PROJECT_ROOT') + + if not root_dir_env: # if no env, use prefs instead + root_dir_env = prefs.root_default + + filepath.root_dir = '' if root_dir_env == None else root_dir_env classes = ( diff --git a/preferences.py b/preferences.py index 1b17f4c..1d3fa12 100644 --- a/preferences.py +++ b/preferences.py @@ -19,6 +19,12 @@ class myaddonPrefs(bpy.types.AddonPreferences): subtype='DIR_PATH', default='') + use_env_root : BoolProperty( + name="Use Environement Root", + description="Use root path specified by environnement keys at startup\nUsing key 'ZIP_ROOT' or 'PROJECT_ROOT' if exists (priority to key ZIP_ROOT if both are set)\nElse always use prefs.", + default=True, + ) + def draw(self, context): layout = self.layout col = layout.column() @@ -28,6 +34,7 @@ class myaddonPrefs(bpy.types.AddonPreferences): col = layout.column() col.label(text='If specified, will be the default root folder path when using export to Zip') col.label(text='Typically the root folder of the current project') + col.prop(self, 'use_env_root')