diff --git a/src/blenderbim/blenderbim/bim/module/structural/__init__.py b/src/blenderbim/blenderbim/bim/module/structural/__init__.py index eaac7afdc2..d543d5dc13 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/structural/__init__.py @@ -16,6 +16,9 @@ classes = ( operator.RemoveStructuralBoundaryCondition, operator.EnableEditingStructuralBoundaryCondition, operator.DisableEditingStructuralBoundaryCondition, + operator.AddStructuralMemberConnection, + operator.EnableEditingStructuralConnectionCondition, + operator.RemoveStructuralConnectionCondition, prop.StructuralAnalysisModel, prop.BIMStructuralProperties, prop.BIMObjectStructuralProperties, diff --git a/src/blenderbim/blenderbim/bim/module/structural/operator.py b/src/blenderbim/blenderbim/bim/module/structural/operator.py index bc4144a841..d193941a3e 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/operator.py +++ b/src/blenderbim/blenderbim/bim/module/structural/operator.py @@ -6,6 +6,30 @@ from blenderbim.bim.ifc import IfcStore from ifcopenshell.api.structural.data import Data +class AddStructuralMemberConnection(bpy.types.Operator): + bl_idname = "bim.add_structural_member_connection" + bl_label = "Add Structural Member Connection" + + def execute(self, context): + return {"FINISHED"} + + +class EnableEditingStructuralConnectionCondition(bpy.types.Operator): + bl_idname = "bim.enable_editing_structural_connection_condition" + bl_label = "Enable Editing Structural Connection Condition" + + def execute(self, context): + return {"FINISHED"} + + +class RemoveStructuralConnectionCondition(bpy.types.Operator): + bl_idname = "bim.remove_structural_connection_condition" + bl_label = "Remove Structural Connection Condition" + + def execute(self, context): + return {"FINISHED"} + + class AddStructuralBoundaryCondition(bpy.types.Operator): bl_idname = "bim.add_structural_boundary_condition" bl_label = "Add Structural Boundary Condition" diff --git a/src/blenderbim/blenderbim/bim/module/structural/prop.py b/src/blenderbim/blenderbim/bim/module/structural/prop.py index ebd8199615..a642b047cd 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/prop.py +++ b/src/blenderbim/blenderbim/bim/module/structural/prop.py @@ -31,4 +31,4 @@ class BIMStructuralProperties(PropertyGroup): class BIMObjectStructuralProperties(PropertyGroup): boundary_condition_attributes: CollectionProperty(name="Boundary Condition Attributes", type=Attribute) is_editing_boundary_condition: BoolProperty(name="Is Editing Boundary Condition", default=False) - connected_structural_members: CollectionProperty(name="Connected Structural Members", type=Attribute) + is_editing_connection_conditions: BoolProperty(name="Is Editing Connection Conditions", default=False) diff --git a/src/blenderbim/blenderbim/bim/module/structural/ui.py b/src/blenderbim/blenderbim/bim/module/structural/ui.py index 006f0ff168..cee838b32c 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/ui.py +++ b/src/blenderbim/blenderbim/bim/module/structural/ui.py @@ -102,27 +102,20 @@ class BIM_PT_connected_structural_members(Panel): self.data = Data.connected_structural_members[self.oprops.ifc_definition_id] - for member in self.data: + row = self.layout.row(align=True) + row.label(text=f"{len(self.data.keys())} Connected Structural Members Found", icon="CON_TRACKTO") + row.operator("bim.add_structural_member_connection", text="", icon="ADD") + + for _,rel in self.data.items(): row = self.layout.row(align=True) - row.label(text=str(member)) - - # row = self.layout.row(align=True) - # if self.data and self.props.is_editing_boundary_condition: - # row.label(text=self.data["type"], icon="CON_TRACKTO") - # row.operator("bim.edit_structural_boundary_condition", text="", icon="CHECKMARK") - # row.operator("bim.disable_editing_structural_boundary_condition", text="", icon="X") - # elif self.data and not self.props.is_editing_boundary_condition: - # row.label(text=self.data["type"], icon="CON_TRACKTO") - # row.operator("bim.enable_editing_structural_boundary_condition", text="", icon="GREASEPENCIL") - # row.operator("bim.remove_structural_boundary_condition", text="", icon="X") - # else: - # row.label(text="No Boundary Condition Found", icon="CON_TRACKTO") - # row.operator("bim.add_structural_boundary_condition", text="", icon="ADD") - - # if self.props.is_editing_boundary_condition: - # self.draw_editable_ui(context) - # else: - # self.draw_read_only_ui(context) + if self.props.is_editing_connection_conditions: + row.label(text=str(rel["RelatingStructuralMember"])) + # row.operator("bim.edit_structural_member_connection", text="", icon="CHECKMARK") + # row.operator("bim.disable_editing_structural_member_connection", text="", icon="X") + else: + row.label(text=f"To Member #{rel['RelatingStructuralMember']}") + row.operator("bim.enable_editing_structural_connection_condition", text="", icon="GREASEPENCIL") + row.operator("bim.remove_structural_connection_condition", text="", icon="X") class BIM_PT_structural_analysis_models(Panel): diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/data.py b/src/ifcopenshell-python/ifcopenshell/api/structural/data.py index c8bc9d5404..2ef7ce678d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/structural/data.py +++ b/src/ifcopenshell-python/ifcopenshell/api/structural/data.py @@ -1,30 +1,35 @@ class Data: is_loaded = False products = {} - boundary_conditions = {} structural_analysis_models = {} + boundary_conditions = {} + connected_structural_members = {} + connection_conditions = {} @classmethod def purge(cls): cls.is_loaded = False cls.products = {} + cls.structural_analysis_models = {} cls.boundary_conditions = {} cls.connected_structural_members = {} - cls.structural_analysis_models = {} + cls.connection_conditions = {} @classmethod def load(cls, file, product_id=None): cls._file = file + if not cls._file: + return if product_id: - cls.boundary_conditions = {} return cls.load_structural_connection(product_id) - cls.products = {} - cls.structural_analysis_models = {} cls.load_structural_analysis_models() cls.is_loaded = True @classmethod def load_structural_analysis_models(cls): + cls.products = {} + cls.structural_analysis_models = {} + for model in cls._file.by_type("IfcStructuralAnalysisModel"): if model.IsGroupedBy: for rel in model.IsGroupedBy: @@ -44,10 +49,16 @@ class Data: has_results.append(result_group.id()) data["HasResults"] = has_results + data["SharedPlacement"] = model.SharedPlacement.id() + cls.structural_analysis_models[model.id()] = data @classmethod def load_structural_connection(cls, product_id): + cls.boundary_conditions = {} + cls.connected_structural_members = {} + # cls.connection_conditions = {} + connection = cls._file.by_id(product_id) if connection.AppliedCondition: data = connection.AppliedCondition.get_info() @@ -59,8 +70,33 @@ class Data: data = {} cls.boundary_conditions[connection.id()] = data - cls.connected_structural_members[connection.id()] = [ - rel.RelatingStructuralMember.id() - for rel in connection.ConnectsStructuralMembers or [] - ] + cls.connected_structural_members[connection.id()] = {} + for rel in connection.ConnectsStructuralMembers or []: + data = rel.get_info() + del data["OwnerHistory"] + data["RelatingStructuralMember"] = rel.RelatingStructuralMember.id() + data["RelatedStructuralConnection"] = rel.RelatedStructuralConnection.id() + del data["ConditionCoordinateSystem"] # TODO: consider orientation + del data["AppliedCondition"] # delete and parse below + if rel.is_a("IfcRelConnectsWithEccentricity"): + data["ConnectionConstraint"] = rel.ConnectionConstraint # TODO + cls.connected_structural_members[connection.id()][rel.id()] = data + + if rel.AppliedCondition: + data = rel.AppliedCondition.get_info() + for key, value in data.items(): + if not value or key in ["Name", "type", "id"]: + continue + data[key] = value.wrappedValue + else: + data = {} + cls.connection_conditions[rel.id()] = data + + print(cls.connected_structural_members) + print(cls.connection_conditions) + + # cls.connected_structural_members[connection.id()] = [ + # rel.id() + # for rel in connection.ConnectsStructuralMembers or [] + # ] \ No newline at end of file