From a98cad161e1e773d2f6aebfce758a775ec427e2b Mon Sep 17 00:00:00 2001 From: falken10vdl Date: Mon, 29 Sep 2025 09:31:00 +0200 Subject: [PATCH] Refactor mass and time units panel into collapsible section using .panel method in project wizard UI --- .../bonsai/bim/module/project/__init__.py | 2 -- src/bonsai/bonsai/bim/module/project/ui.py | 31 ++++++++----------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/project/__init__.py b/src/bonsai/bonsai/bim/module/project/__init__.py index 7e1bdb7ff0..1316eb0325 100644 --- a/src/bonsai/bonsai/bim/module/project/__init__.py +++ b/src/bonsai/bonsai/bim/module/project/__init__.py @@ -114,7 +114,6 @@ def register(): kmi = km.keymap_items.new("bim.save_project", "S", "PRESS", ctrl=True) kmi.properties.should_save_as = False addon_keymaps.append((km, kmi)) - bpy.utils.register_class(ui.BIM_PT_mass_time_units) def unregister(): @@ -132,4 +131,3 @@ def unregister(): for km, kmi in addon_keymaps: km.keymap_items.remove(kmi) addon_keymaps.clear() - bpy.utils.unregister_class(ui.BIM_PT_mass_time_units) diff --git a/src/bonsai/bonsai/bim/module/project/ui.py b/src/bonsai/bonsai/bim/module/project/ui.py index f1b087e34b..b0dae84afe 100644 --- a/src/bonsai/bonsai/bim/module/project/ui.py +++ b/src/bonsai/bonsai/bim/module/project/ui.py @@ -358,29 +358,24 @@ class BIM_PT_new_project_wizard(Panel): row.prop(props, "volume_unit", text="Volume Unit") row = self.layout.row() prop_with_search(self.layout, pprops, "template_file", text="Template") + + header, body = self.layout.panel("Mass and Time Units", default_closed=True) + if header: + header.label(text="Mass and Time Units") + if body: + label = "Add Mass and Time Units" if not props.add_mass_time_units else "Remove Mass and Time Units" + body.prop(props, "add_mass_time_units", toggle=True, text=label) + if props.add_mass_time_units: + row = body.row() + row.prop(props, "mass_unit", text="Mass Unit") + row = body.row() + row.prop(props, "time_unit", text="Time Unit") + self.layout.use_property_split = True row = self.layout.row() row.operator("bim.create_project") -class BIM_PT_mass_time_units(Panel): - bl_label = "Mass and Time Units" - bl_idname = "BIM_PT_mass_time_units" - bl_options = {"DEFAULT_CLOSED"} - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "scene" - bl_parent_id = "BIM_PT_new_project_wizard" - def draw(self, context): - layout = self.layout - props = tool.Blender.get_bim_props() - label = "Add Mass and Time Units" if not props.add_mass_time_units else "Remove Mass and Time Units" - layout.prop(props, "add_mass_time_units", toggle=True, text=label) - if props.add_mass_time_units: - row = layout.row() - row.prop(props, "mass_unit", text="Mass Unit") - row = layout.row() - row.prop(props, "time_unit", text="Time Unit") class BIM_PT_project_library(Panel): bl_label = "Project Library"