From b217860840a2dd85a1fc535044be94ad4d28fc6c Mon Sep 17 00:00:00 2001 From: Gorgious Date: Fri, 24 Sep 2021 11:29:37 +0200 Subject: [PATCH] Enable adding fillings from the opening object ui --- .../blenderbim/bim/module/void/ui.py | 121 ++++++++++-------- 1 file changed, 70 insertions(+), 51 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/void/ui.py b/src/blenderbim/blenderbim/bim/module/void/ui.py index 572ad8f71a..1deb0c8980 100644 --- a/src/blenderbim/blenderbim/bim/module/void/ui.py +++ b/src/blenderbim/blenderbim/bim/module/void/ui.py @@ -38,60 +38,79 @@ class BIM_PT_voids(Panel): def draw(self, context): props = context.active_object.BIMObjectProperties + file = IfcStore.get_file() if props.ifc_definition_id not in Data.products: - Data.load(IfcStore.get_file(), props.ifc_definition_id) + Data.load(file, props.ifc_definition_id) - row = self.layout.row(align=True) - if len(context.selected_objects) == 2: - op = row.operator("bim.add_opening", icon="ADD", text="Add Opening") - for obj in context.selected_objects: - if "IfcOpeningElement" in obj.name or not obj.BIMObjectProperties.ifc_definition_id: - op.opening = obj.name - elif len(obj.children) == 1 and not obj.children[0].BIMObjectProperties.ifc_definition_id: - op.opening = obj.children[0].name - else: - op.obj = obj.name - - opening_id = None - obj_name = None - for obj in context.selected_objects: - if obj.BIMObjectProperties.ifc_definition_id in Data.openings: - opening_id = obj.BIMObjectProperties.ifc_definition_id - elif obj.BIMObjectProperties.ifc_definition_id in Data.fillings: - opening_id = Data.fillings[obj.BIMObjectProperties.ifc_definition_id]["FillsVoid"] - else: - obj_name = obj.name - if opening_id and obj_name: - op = row.operator("bim.remove_opening", icon="X", text="Remove Opening") - op.opening_id = opening_id - op.obj = obj_name - else: - row.label(text="Select an opening and an element to modify", icon="HELP") - - opening_ids = Data.products[props.ifc_definition_id] - if not opening_ids: - row = self.layout.row(align=True) - row.label(text="No Openings", icon="SELECT_SUBTRACT") - for opening_id in opening_ids: - opening = Data.openings[opening_id] - if opening["HasFillings"]: - for filling_id in opening["HasFillings"]: - filling = Data.fillings[filling_id] - row = self.layout.row(align=True) - row.label(text=opening["Name"], icon="SELECT_SUBTRACT") - row.label(text=filling["Name"], icon="SELECT_INTERSECT") - else: - row = self.layout.row(align=True) - row.label(text=opening["Name"], icon="SELECT_SUBTRACT") - op = row.operator("bim.remove_opening", icon="X", text="") - op.opening_id = opening_id - - if props.ifc_definition_id not in Data.fillings: + element = file.by_id(props.ifc_definition_id) + if element.is_a("IfcOpeningElement"): + self.layout.label(text="Select a filling") row = self.layout.row(align=True) row.prop(context.scene.VoidProperties, "desired_opening", text="", icon="SELECT_INTERSECT") - row.operator("bim.add_filling", icon="ADD", text="") + op = row.operator("bim.add_filling", icon="ADD", text="") + if context.scene.VoidProperties.desired_opening: + op.opening = context.active_object.name + op.obj = context.scene.VoidProperties.desired_opening.name + if props.ifc_definition_id in Data.openings and Data.openings[props.ifc_definition_id]["HasFillings"]: + for filling_id in Data.openings[props.ifc_definition_id]["HasFillings"]: + if filling_id not in Data.fillings: + continue + row = self.layout.row(align=True) + row.label(text=Data.fillings[filling_id]["Name"], icon="SELECT_INTERSECT") + op = row.operator("bim.remove_filling", icon="X", text="") + op.obj = IfcStore.id_map[filling_id].name else: - opening = Data.openings[Data.fillings[props.ifc_definition_id]["FillsVoid"]] row = self.layout.row(align=True) - row.label(text=opening["Name"], icon="SELECT_INTERSECT") - row.operator("bim.remove_filling", icon="X", text="") + if len(context.selected_objects) == 2: + op = row.operator("bim.add_opening", icon="ADD", text="Add Opening") + for obj in context.selected_objects: + if "IfcOpeningElement" in obj.name or not obj.BIMObjectProperties.ifc_definition_id: + op.opening = obj.name + elif len(obj.children) == 1 and not obj.children[0].BIMObjectProperties.ifc_definition_id: + op.opening = obj.children[0].name + else: + op.obj = obj.name + + opening_id = None + obj_name = None + for obj in context.selected_objects: + if obj.BIMObjectProperties.ifc_definition_id in Data.openings: + opening_id = obj.BIMObjectProperties.ifc_definition_id + elif obj.BIMObjectProperties.ifc_definition_id in Data.fillings: + opening_id = Data.fillings[obj.BIMObjectProperties.ifc_definition_id]["FillsVoid"] + else: + obj_name = obj.name + if opening_id and obj_name: + op = row.operator("bim.remove_opening", icon="X", text="Remove Opening") + op.opening_id = opening_id + op.obj = obj_name + else: + row.label(text="Select an opening and an element to modify", icon="HELP") + + opening_ids = Data.products[props.ifc_definition_id] + if not opening_ids: + row = self.layout.row(align=True) + row.label(text="No Openings", icon="SELECT_SUBTRACT") + for opening_id in opening_ids: + opening = Data.openings[opening_id] + if opening["HasFillings"]: + for filling_id in opening["HasFillings"]: + filling = Data.fillings[filling_id] + row = self.layout.row(align=True) + row.label(text=opening["Name"], icon="SELECT_SUBTRACT") + row.label(text=filling["Name"], icon="SELECT_INTERSECT") + else: + row = self.layout.row(align=True) + row.label(text=opening["Name"], icon="SELECT_SUBTRACT") + op = row.operator("bim.remove_opening", icon="X", text="") + op.opening_id = opening_id + + if props.ifc_definition_id not in Data.fillings: + row = self.layout.row(align=True) + row.prop(context.scene.VoidProperties, "desired_opening", text="", icon="SELECT_INTERSECT") + row.operator("bim.add_filling", icon="ADD", text="") + else: + opening = Data.openings[Data.fillings[props.ifc_definition_id]["FillsVoid"]] + row = self.layout.row(align=True) + row.label(text=opening["Name"], icon="SELECT_INTERSECT") + row.operator("bim.remove_filling", icon="X", text="")