From ad815b697e65d2d5dd13a7234f7486e3eea50740 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Thu, 2 Jan 2025 14:12:26 +0100 Subject: [PATCH] Fix #5570 : Regen button now appears in the toolbar for windows and doors --- src/bonsai/bonsai/bim/module/model/data.py | 14 ++++++++++++++ src/bonsai/bonsai/bim/module/model/workspace.py | 17 ++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/data.py b/src/bonsai/bonsai/bim/module/model/data.py index 55715b517c..17b66f49f4 100644 --- a/src/bonsai/bonsai/bim/module/model/data.py +++ b/src/bonsai/bonsai/bim/module/model/data.py @@ -83,6 +83,7 @@ class AuthoringData: # Only after .active_material_usage() and .active_class() cls.data["is_flippable_element"] = cls.is_flippable_element() + cls.data["is_regenable_element"] = cls.is_regenable_element() @classmethod def default_container(cls) -> str | None: @@ -171,6 +172,19 @@ class AuthoringData: "IfcDoorStandardCase", ) + @classmethod + def is_regenable_element(cls): + if cls.data["active_material_usage"] in ("LAYER2", "PROFILE") and cls.data["active_class"] not in ( + "IfcCableCarrierSegment", + "IfcCableSegment", + "IfcDuctSegment", + "IfcPipeSegment", + ): + return True + if cls.data["active_class"] in ("IfcWindow", "IfcWindowStandardCase", "IfcDoor", "IfcDoorStandardCase"): + return True + return False + @classmethod def has_visible_openings(cls): if active_object := tool.Blender.get_active_object(): diff --git a/src/bonsai/bonsai/bim/module/model/workspace.py b/src/bonsai/bonsai/bim/module/model/workspace.py index 3aacbcc817..319afe4250 100644 --- a/src/bonsai/bonsai/bim/module/model/workspace.py +++ b/src/bonsai/bonsai/bim/module/model/workspace.py @@ -771,24 +771,11 @@ class EditObjectUI: def draw_regen_operations(cls, row): custom_icon = custom_icon_previews.get("REGEN", custom_icon_previews["IFC"]).icon_id - if AuthoringData.data["active_material_usage"] == "LAYER2": + if AuthoringData.data["is_regenable_element"]: op = row.operator("bim.hotkey", text="", icon_value=custom_icon) - description = f"{bpy.ops.bim.recalculate_wall.__doc__}\n\nHotkey: S G" + description = "Recalculate Element Geometry\nHotkey: S G" op.hotkey = "S_G" op.description = description.strip() - elif AuthoringData.data["active_material_usage"] == "PROFILE": - if AuthoringData.data["active_class"] in ( - "IfcCableCarrierSegment", - "IfcCableSegment", - "IfcDuctSegment", - "IfcPipeSegment", - ): - pass - else: - op = row.operator("bim.hotkey", text="", icon_value=custom_icon) - description = f"{bpy.ops.bim.recalculate_profile.__doc__}\n\nHotkey: S G" - op.hotkey = "S_G" - op.description = description.strip() if PortData.data["total_ports"] > 0: op = row.operator("bim.hotkey", text="", icon_value=custom_icon)