bl_info = { "name": "Custom Shelf", "author": "Christophe Seux", "description": "Adds buttons to launch custom python scripts in the User panel.", "version": (0, 3, 2), "blender": (4, 0, 2), "location": "View3D > User Panel", "doc_url": "https://gitlab.com/autour-de-minuit/blender/custom_shelf/-/blob/main/README.md", "tracker_url": "https://gitlab.com/autour-de-minuit/blender/custom_shelf/-/issues", "support": "COMMUNITY", "category": "User"} if "bpy" in locals(): import importlib importlib.reload(operators) importlib.reload(panels) importlib.reload(functions) importlib.reload(properties) from . utils import report from . functions import read_shelves from . import operators from . import properties from . import ui from .properties import CustomShelfSettings,CustomShelfProps import bpy import os bl_classes = [ properties.AdditionnalShelves, properties.CustomShelfProps, properties.CustomShelfSettings, properties.CustomShelfPrefs, operators.CSHELF_OT_refresh, operators.CSHELF_OT_add_shelf_folder, operators.CSHELF_OT_remove_shelf_folder, operators.CSHELF_OT_open_shelf_folder, operators.CSHELF_OT_add_script, operators.CSHELF_OT_set_tag_filter, ui.CSHELF_MT_text_editor ] def draw_menu(self, context): self.layout.menu('CSHELF_MT_text_editor') def register(): for bl_class in bl_classes : bpy.utils.register_class(bl_class) bpy.types.Scene.CustomShelf = bpy.props.PointerProperty(type=CustomShelfSettings) bpy.types.WindowManager.CustomShelf = bpy.props.PointerProperty(type=CustomShelfProps) bpy.types.TEXT_MT_editor_menus.append(draw_menu) env_shelves = os.getenv("CUSTOM_SHELVES") if env_shelves: shelves = env_shelves.split(os.pathsep) prefs = bpy.context.preferences.addons[__name__].preferences # prefs.global_shelves = '' # prefs.additionnal_shelves.clear() for path in shelves: shelf = next((s for s in prefs.additionnal_shelves if s.path == path), None) if not shelf: shelf = prefs.additionnal_shelves.add() shelf.path = path read_shelves() def unregister(): # unregister panel : for panel in CustomShelfSettings.panel_list : try : bpy.utils.unregister_class(panel) except Exception: pass bpy.types.TEXT_MT_editor_menus.remove(draw_menu) del bpy.types.Scene.CustomShelf del bpy.types.WindowManager.CustomShelf for bl_class in bl_classes : bpy.utils.unregister_class(bl_class)