diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index 0c28e5d43a..0893ce404f 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -1138,7 +1138,22 @@ class IfcImporter: bpy.ops.view3d.view_selected() bpy.ops.object.select_all(action="DESELECT") - def setup_arrays(self, annotations_to_import: Optional[set[ifcopenshell.entity_instance]] = None) -> None: + def setup_arrays( + self, + *, + annotations_to_import: Optional[set[ifcopenshell.entity_instance]] = None, + openings_to_import: Optional[set[ifcopenshell.entity_instance]] = None, + ) -> None: + # During base import some elements are skipped. + is_base_import = True + elements_to_import: set[ifcopenshell.entity_instance] = set() + if annotations_to_import is not None: + is_base_import = False + elements_to_import = annotations_to_import + elif openings_to_import is not None: + is_base_import = False + elements_to_import = openings_to_import + for pset in self.file.by_type("IfcPropertySet"): if pset.Name != "BBIM_Array": continue @@ -1148,12 +1163,11 @@ class IfcImporter: for rel in pset.DefinesOccurrence: element: ifcopenshell.entity_instance for element in rel.RelatedObjects: - if annotations_to_import is None: - # IfcAnnotations are not loaded during base import. - if element.is_a("IfcAnnotation"): + if is_base_import: + if element.is_a("IfcAnnotation") or element.is_a("IfcOpeningElement"): continue else: - if element not in annotations_to_import: + if element not in elements_to_import: continue for i in range(len(data)): tool.Blender.Modifier.Array.set_children_lock_state(element, i, True) diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 55e0426c23..7cbf5a420b 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -785,7 +785,7 @@ class Drawing(bonsai.core.tool.Drawing): ifc_importer.load_existing_meshes() ifc_importer.material_creator.load_existing_materials() ifc_importer.create_generic_elements(elements) - ifc_importer.setup_arrays(elements) + ifc_importer.setup_arrays(annotations_to_import=elements) for obj in ifc_importer.added_data.values(): tool.Collector.assign(obj) diff --git a/src/bonsai/bonsai/tool/model.py b/src/bonsai/bonsai/tool/model.py index fdf68461e0..ca2c009feb 100644 --- a/src/bonsai/bonsai/tool/model.py +++ b/src/bonsai/bonsai/tool/model.py @@ -587,13 +587,15 @@ class Model(bonsai.core.tool.Model): def load_openings(cls, openings: list[ifcopenshell.entity_instance]) -> Iterable[bpy.types.Object]: if not openings: return [] + elements = set(openings) ifc_import_settings = import_ifc.IfcImportSettings.factory() ifc_importer = import_ifc.IfcImporter(ifc_import_settings) ifc_importer.file = tool.Ifc.get() ifc_importer.calculate_unit_scale() ifc_importer.process_context_filter() ifc_importer.material_creator.load_existing_materials() - ifc_importer.create_generic_elements(set(openings)) + ifc_importer.create_generic_elements(elements) + ifc_importer.setup_arrays(openings_to_import=elements) for opening_obj in ifc_importer.added_data.values(): tool.Collector.assign(opening_obj, should_clean_users_collection=False) return ifc_importer.added_data.values()