diff --git a/src/blenderbim/blenderbim/bim/module/type/__init__.py b/src/blenderbim/blenderbim/bim/module/type/__init__.py index dc1afcd7e2..e55172a517 100644 --- a/src/blenderbim/blenderbim/bim/module/type/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/type/__init__.py @@ -7,6 +7,7 @@ classes = ( operator.EnableEditingType, operator.DisableEditingType, operator.SelectSimilarType, + operator.SelectTypeObjects, prop.BIMTypeProperties, prop.BIMTypeObjectProperties, ui.BIM_PT_type, diff --git a/src/blenderbim/blenderbim/bim/module/type/operator.py b/src/blenderbim/blenderbim/bim/module/type/operator.py index 7016be6f74..c3d9ee2b8b 100644 --- a/src/blenderbim/blenderbim/bim/module/type/operator.py +++ b/src/blenderbim/blenderbim/bim/module/type/operator.py @@ -133,3 +133,20 @@ class SelectSimilarType(bpy.types.Operator): if obj.BIMObjectProperties.ifc_definition_id in related_objects: obj.select_set(True) return {"FINISHED"} + + +class SelectTypeObjects(bpy.types.Operator): + bl_idname = "bim.select_type_objects" + bl_label = "Select Type Objects" + bl_options = {"REGISTER", "UNDO"} + relating_type: bpy.props.StringProperty() + + def execute(self, context): + self.file = IfcStore.get_file() + relating_type = bpy.data.objects.get(self.relating_type) if self.relating_type else bpy.context.active_object + oprops = relating_type.BIMObjectProperties + related_objects = Data.types[oprops.ifc_definition_id] + for obj in bpy.context.visible_objects: + if obj.BIMObjectProperties.ifc_definition_id in related_objects: + obj.select_set(True) + return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/type/ui.py b/src/blenderbim/blenderbim/bim/module/type/ui.py index 564afbc969..b5ad10687d 100644 --- a/src/blenderbim/blenderbim/bim/module/type/ui.py +++ b/src/blenderbim/blenderbim/bim/module/type/ui.py @@ -17,20 +17,32 @@ class BIM_PT_type(Panel): return False if not IfcStore.get_element(props.ifc_definition_id): return False - if props.ifc_definition_id not in Data.products: + if props.ifc_definition_id not in Data.products and props.ifc_definition_id not in Data.types: Data.load(IfcStore.get_file(), props.ifc_definition_id) - if not Data.products[props.ifc_definition_id]: + if props.ifc_definition_id not in Data.products and props.ifc_definition_id not in Data.types: + return False + if not Data.products.get(props.ifc_definition_id, None) and not Data.types.get(props.ifc_definition_id, None): return False return True - def draw(self, context): + oprops = context.active_object.BIMObjectProperties + + if oprops.ifc_definition_id in Data.products: + self.draw_product_ui(context) + else: + self.draw_type_ui(context) + + def draw_type_ui(self, context): + props = context.active_object.BIMTypeProperties + oprops = context.active_object.BIMObjectProperties + row = self.layout.row(align=True) + row.label(text=f"{len(Data.types[oprops.ifc_definition_id])} Typed Objects") + row.operator("bim.select_type_objects", icon="RESTRICT_SELECT_OFF", text="") + + def draw_product_ui(self, context): props = context.active_object.BIMTypeProperties oprops = context.active_object.BIMObjectProperties - if not oprops.ifc_definition_id: - return - if oprops.ifc_definition_id not in Data.products: - Data.load(IfcStore.get_file(), oprops.ifc_definition_id) if props.is_editing_type: row = self.layout.row(align=True)