From 1820f72bc4a7bd6bf4d3363e786770cced088260 Mon Sep 17 00:00:00 2001 From: Jesusbill Date: Wed, 31 Mar 2021 18:58:02 +0200 Subject: [PATCH] You can now remove structural connection conditions + minor mods --- .../bim/module/structural/operator.py | 21 ++++++++++++------- .../blenderbim/bim/module/structural/ui.py | 12 ++++++----- .../ifcopenshell/api/structural/data.py | 6 ++---- .../remove_structural_boundary_condition.py | 5 ++--- .../remove_structural_connection_condition.py | 19 +++++++++++++++++ 5 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py diff --git a/src/blenderbim/blenderbim/bim/module/structural/operator.py b/src/blenderbim/blenderbim/bim/module/structural/operator.py index 131fbf548a..517eb0b2b3 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/operator.py +++ b/src/blenderbim/blenderbim/bim/module/structural/operator.py @@ -24,9 +24,6 @@ class EnableEditingStructuralConnectionCondition(bpy.types.Operator): oprops = obj.BIMObjectProperties props = obj.BIMStructuralProperties applied_condition_id = Data.connects_structural_members[self.connects_structural_member]["AppliedCondition"] - if applied_condition_id: - bpy.ops.bim.enable_editing_structural_boundary_condition(boundary_condition=applied_condition_id) - props.active_connects_structural_member = self.connects_structural_member return {"FINISHED"} @@ -45,8 +42,15 @@ class DisableEditingStructuralConnectionCondition(bpy.types.Operator): class RemoveStructuralConnectionCondition(bpy.types.Operator): bl_idname = "bim.remove_structural_connection_condition" bl_label = "Remove Structural Connection Condition" + connects_structural_member: bpy.props.IntProperty() def execute(self, context): + file = IfcStore.get_file() + relation = file.by_id(self.connects_structural_member) + connection = relation.RelatedStructuralConnection + ifcopenshell.api.run("structural.remove_structural_connection_condition", file, **{"relation": relation}) + + Data.load(IfcStore.get_file(), connection.id()) return {"FINISHED"} @@ -68,14 +72,17 @@ class AddStructuralBoundaryCondition(bpy.types.Operator): class RemoveStructuralBoundaryCondition(bpy.types.Operator): bl_idname = "bim.remove_structural_boundary_condition" - bl_label = "Enable Editing Structural Boundary Condition" + bl_label = "Remove Structural Boundary Condition" + connection: bpy.props.IntProperty() def execute(self, context): - obj = context.active_object file = IfcStore.get_file() - connection = file.by_id(obj.BIMObjectProperties.ifc_definition_id) + connection = file.by_id(self.connection) ifcopenshell.api.run("structural.remove_structural_boundary_condition", file, **{"connection": connection}) - Data.load(IfcStore.get_file(), connection.id()) + if connection.is_a("IfcRelConnectsStructuralMember"): + Data.load(IfcStore.get_file(), connection.RelatedStructuralConnection.id()) + else: + Data.load(IfcStore.get_file(), connection.id()) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/structural/ui.py b/src/blenderbim/blenderbim/bim/module/structural/ui.py index 6c38cdf02e..0e8054feb2 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/ui.py +++ b/src/blenderbim/blenderbim/bim/module/structural/ui.py @@ -17,12 +17,12 @@ def draw_boundary_condition_ui(layout, boundary_condition_id, connection_id, pro row.operator("bim.disable_editing_structural_boundary_condition", text="", icon="X") elif props.active_boundary_condition and props.active_boundary_condition != boundary_condition_id: row.label(text=data["type"], icon="CON_TRACKTO") - row.operator("bim.remove_structural_boundary_condition", text="", icon="X") + row.operator("bim.remove_structural_boundary_condition", text="", icon="X").connection = connection_id else: row.label(text=data["type"], icon="CON_TRACKTO") op = row.operator("bim.enable_editing_structural_boundary_condition", text="", icon="GREASEPENCIL") op.boundary_condition = data["id"] - row.operator("bim.remove_structural_boundary_condition", text="", icon="X") + row.operator("bim.remove_structural_boundary_condition", text="", icon="X").connection = connection_id if props.active_boundary_condition and props.active_boundary_condition == boundary_condition_id: draw_boundary_condition_editable_ui(layout, props) @@ -124,14 +124,16 @@ class BIM_PT_connected_structural_members(Panel): row.label(text=f"To Member #{rel['RelatingStructuralMember']}") if self.props.active_connects_structural_member and self.props.active_connects_structural_member == rel_id: row.operator("bim.disable_editing_structural_connection_condition", text="", icon="CHECKMARK") - row.operator("bim.disable_editing_structural_connection_condition", text="", icon="X") + row.enabled = self.props.active_boundary_condition != rel["AppliedCondition"] self.draw_editable_ui(context, self.layout, rel) elif self.props.active_connects_structural_member: - row.operator("bim.remove_structural_connection_condition", text="", icon="X") + op = row.operator("bim.remove_structural_connection_condition", text="", icon="X") + op.connects_structural_member = rel_id else: op = row.operator("bim.enable_editing_structural_connection_condition", text="", icon="GREASEPENCIL") op.connects_structural_member = rel_id - row.operator("bim.remove_structural_connection_condition", text="", icon="X") + op = row.operator("bim.remove_structural_connection_condition", text="", icon="X") + op.connects_structural_member = rel_id def draw_editable_ui(self, context, layout, data): box = layout.box() diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/data.py b/src/ifcopenshell-python/ifcopenshell/api/structural/data.py index 75537c5815..cb55d11874 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/structural/data.py +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/data.py @@ -2,9 +2,8 @@ class Data: is_loaded = False products = {} structural_analysis_models = {} - boundary_conditions = {} - members = {} connections = {} + boundary_conditions = {} connects_structural_members = {} @classmethod @@ -12,9 +11,8 @@ class Data: cls.is_loaded = False cls.products = {} cls.structural_analysis_models = {} - cls.boundary_conditions = {} - cls.members = {} cls.connections = {} + cls.boundary_conditions = {} cls.connects_structural_members = {} @classmethod diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_boundary_condition.py b/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_boundary_condition.py index afee179e0b..48ca3354df 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_boundary_condition.py +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_boundary_condition.py @@ -8,7 +8,6 @@ class Usecase: def execute(self): if not self.settings["connection"].AppliedCondition: return - if len(self.file.get_inverse(self.settings["connection"].AppliedCondition)) > 1: - self.settings["connection"].AppliedCondition = None - else: + if len(self.file.get_inverse(self.settings["connection"].AppliedCondition)) == 1: self.file.remove(self.settings["connection"].AppliedCondition) + self.settings["connection"].AppliedCondition = None diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py b/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py new file mode 100644 index 0000000000..0b376f9895 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py @@ -0,0 +1,19 @@ +import ifcopenshell.api + + +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"relation": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + if self.settings["relation"].AppliedCondition: + ifcopenshell.api.run( + "structural.remove_structural_boundary_condition", + self.file, + **{"connection": self.settings["relation"].RelatedStructuralConnection} + ) + self.file.remove(self.settings["relation"]) +