From 5f2acb43b1eff490717431d58340406c09a8d675 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 23 Sep 2022 23:41:37 +1000 Subject: [PATCH] You can now recalculate connections manually for profiles --- .../blenderbim/bim/module/model/__init__.py | 1 + .../blenderbim/bim/module/model/profile.py | 30 +++++++++++++++++++ .../blenderbim/bim/module/model/workspace.py | 6 ++++ 3 files changed, 37 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/model/__init__.py b/src/blenderbim/blenderbim/bim/module/model/__init__.py index 69d1ac7474..8e6fb64064 100644 --- a/src/blenderbim/blenderbim/bim/module/model/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/model/__init__.py @@ -36,6 +36,7 @@ classes = ( wall.SplitWall, opening.AddElementOpening, profile.ExtendProfile, + profile.RecalculateProfile, prop.BIMModelProperties, prop.ConstrTypeInfo, ui.BIM_PT_authoring, diff --git a/src/blenderbim/blenderbim/bim/module/model/profile.py b/src/blenderbim/blenderbim/bim/module/model/profile.py index 9943b8b27a..acc9143494 100644 --- a/src/blenderbim/blenderbim/bim/module/model/profile.py +++ b/src/blenderbim/blenderbim/bim/module/model/profile.py @@ -863,3 +863,33 @@ class DumbProfileJoiner: final = {"contact": contact, "distance": distance, "end": result[2], "direction": result[3]} return final + + +class RecalculateProfile(bpy.types.Operator): + bl_idname = "bim.recalculate_profile" + bl_label = "Recalculate Profile" + bl_options = {"REGISTER", "UNDO"} + + @classmethod + def poll(cls, context): + return context.selected_objects + + def execute(self, context): + DumbProfileRecalculator().recalculate(context.selected_objects) + return {"FINISHED"} + + +class DumbProfileRecalculator: + def recalculate(self, profiles): + queue = set() + for profile in profiles: + element = tool.Ifc.get_entity(profile) + queue.add((element, profile)) + for rel in getattr(element, "ConnectedTo", []): + queue.add((rel.RelatedElement, tool.Ifc.get_object(rel.RelatedElement))) + for rel in getattr(element, "ConnectedFrom", []): + queue.add((rel.RelatingElement, tool.Ifc.get_object(rel.RelatingElement))) + joiner = DumbProfileJoiner() + for element, profile in queue: + if element.is_a() in ("IfcColumn", "IfcBeam", "IfcMember") and profile: + joiner.recreate_profile(element, profile) diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index e48f1e2506..c525a75771 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -194,6 +194,10 @@ class BimTool(WorkSpaceTool): row.label(text="", icon="EVENT_Y") row.operator("bim.hotkey", text="Mitre").hotkey="S_Y" row = layout.row(align=True) + row.label(text="", icon="EVENT_SHIFT") + row.label(text="", icon="EVENT_G") + row.operator("bim.hotkey", text="Regen Connections").hotkey="S_G" + row = layout.row(align=True) row.operator("bim.extend_profile", icon="X", text="Disconnect").join_type = "" if props.ifc_class in ( @@ -280,6 +284,8 @@ class Hotkey(bpy.types.Operator): def hotkey_S_G(self): if self.has_ifc_class and self.props.ifc_class == "IfcWallType": bpy.ops.bim.recalculate_wall() + elif self.props.ifc_class in ["IfcColumnType", "IfcBeamType", "IfcMemberType"]: + bpy.ops.bim.recalculate_profile() def hotkey_S_T(self): if not self.has_ifc_class: