diff --git a/__init__.py b/__init__.py index 36e2f46..614142f 100644 --- a/__init__.py +++ b/__init__.py @@ -282,6 +282,7 @@ class ABC3D_PT_Panel(bpy.types.Panel): layout.row().label(text='no fonts loaded yet') layout.operator(f"{__name__}.load_installed_fonts", text="load installed fonts", icon=icon) + layout.operator(f"{__name__}.open_asset_directory", text="open asset directory", icon='FILEBROWSER') class ABC3D_PT_LoadFontPanel(bpy.types.Panel): @@ -674,6 +675,28 @@ class ABC3D_OT_InstallFont(bpy.types.Operator): return {'FINISHED'} +class ABC3D_OT_OpenAssetDirectory(bpy.types.Operator): + """Open Asset Directory""" + bl_idname = f"{__name__}.open_asset_directory" + bl_label = "Opens asset directory." + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + preferences = getPreferences(context) + directory = os.path.realpath(preferences.assets_dir) + if os.path.exists(directory): + utils.open_file_browser(directory) + return {'FINISHED'} + else: + butils.ShowMessageBox( + title=f"{__name__} Warning", + icon="ERROR", + message=("Asset directory does not exist.", + f"Command failed trying to access '{directory}'.", + "Please, make sure it exists or chose another directory.")) + return {'CANCELLED'} + + class ABC3D_OT_LoadInstalledFonts(bpy.types.Operator): """Load installed fontfiles from datapath.""" bl_idname = f"{__name__}.load_installed_fonts" @@ -1371,6 +1394,7 @@ classes = ( ABC3D_PT_TextManagement, ABC3D_PT_FontCreation, ABC3D_PT_TextPropertiesPanel, + ABC3D_OT_OpenAssetDirectory, ABC3D_OT_LoadInstalledFonts, ABC3D_OT_LoadFont, ABC3D_OT_AddDefaultMetrics,