diff --git a/src/blenderbim/blenderbim/bim/module/structural/operator.py b/src/blenderbim/blenderbim/bim/module/structural/operator.py index 517eb0b2b3..904586d224 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/operator.py +++ b/src/blenderbim/blenderbim/bim/module/structural/operator.py @@ -11,6 +11,22 @@ class AddStructuralMemberConnection(bpy.types.Operator): bl_label = "Add Structural Member Connection" def execute(self, context): + obj = bpy.context.active_object + oprops = obj.BIMObjectProperties + props = obj.BIMStructuralProperties + file = IfcStore.get_file() + related_structural_connection = file.by_id(oprops.ifc_definition_id) + relating_structural_member = file.by_id(props.relating_structural_member.BIMObjectProperties.ifc_definition_id) + if not relating_structural_member.is_a("IfcStructuralMember"): + return {"FINISHED"} + ifcopenshell.api.run( + "structural.add_structural_member_connection", + file, + relating_structural_member=relating_structural_member, + related_structural_connection=related_structural_connection, + ) + props.relating_structural_member = None + Data.load(IfcStore.get_file(), related_structural_connection.id()) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/structural/prop.py b/src/blenderbim/blenderbim/bim/module/structural/prop.py index ec09012432..f8cc972b87 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/prop.py +++ b/src/blenderbim/blenderbim/bim/module/structural/prop.py @@ -32,3 +32,4 @@ class BIMObjectStructuralProperties(PropertyGroup): boundary_condition_attributes: CollectionProperty(name="Boundary Condition Attributes", type=Attribute) active_boundary_condition: IntProperty(name="Active Boundary Condition") active_connects_structural_member: IntProperty(name="Active Connects Structural Member") + relating_structural_member: PointerProperty(name="Relating Structural Member", type=bpy.types.Object) diff --git a/src/blenderbim/blenderbim/bim/module/structural/ui.py b/src/blenderbim/blenderbim/bim/module/structural/ui.py index 0e8054feb2..87aff9b060 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/ui.py +++ b/src/blenderbim/blenderbim/bim/module/structural/ui.py @@ -115,13 +115,13 @@ class BIM_PT_connected_structural_members(Panel): rel_ids = Data.connections[self.oprops.ifc_definition_id]["ConnectsStructuralMembers"] row = self.layout.row(align=True) - row.label(text=f"{len(rel_ids)} Connected Structural Members", icon="CON_TRACKTO") + row.prop(self.props, "relating_structural_member", text="", icon="CON_TRACKTO") row.operator("bim.add_structural_member_connection", text="", icon="ADD") for rel_id in rel_ids: rel = Data.connects_structural_members[rel_id] row = self.layout.row(align=True) - row.label(text=f"To Member #{rel['RelatingStructuralMember']}") + row.label(text=f"To Member #{IfcStore.get_file().by_id(rel['RelatingStructuralMember']).Name}") 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.enabled = self.props.active_boundary_condition != rel["AppliedCondition"] diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py index 0a220b9de0..1e58a3a87c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py @@ -10,9 +10,6 @@ class Usecase: self.settings[key] = value def execute(self): - return self.file.create_entity("IfcStructuralAnalysisModel", **{ - "GlobalId": ifcopenshell.guid.new(), - "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file), - "Name": "Unnamed", - "PredefinedType": "LOADING_3D" - }) + return ifcopenshell.api.run( + "root.create_entity", self.file, ifc_class="IfcStructuralAnalysisModel", predefined_type="LOADING_3D" + ) diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py new file mode 100644 index 0000000000..e184725bb6 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py @@ -0,0 +1,19 @@ +import ifcopenshell +import ifcopenshell.api + + +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"relating_structural_member": None, "related_structural_connection": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + for connection in self.settings["related_structural_connection"].ConnectsStructuralMembers or []: + if connection.RelatingStructuralMember == self.settings["relating_structural_member"]: + return + rel = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelConnectsStructuralMember") + rel.RelatingStructuralMember = self.settings["relating_structural_member"] + rel.RelatedStructuralConnection = self.settings["related_structural_connection"] + return rel diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/data.py b/src/ifcopenshell-python/ifcopenshell/api/structural/data.py index cb55d11874..0165ab64f9 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/structural/data.py +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/data.py @@ -49,7 +49,7 @@ class Data: has_results.append(result_group.id()) data["HasResults"] = has_results - data["SharedPlacement"] = model.SharedPlacement.id() + data["SharedPlacement"] = model.SharedPlacement.id() if model.SharedPlacement else None cls.structural_analysis_models[model.id()] = data