From dc46afc2272c97c066c323197b5da77c764f94ef Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 29 Apr 2025 17:26:08 +0500 Subject: [PATCH] Setup array constraints for annotations that use paramatric arrays Previously you was able to add parametric array to annotations but constraint would be missing on file reload. --- src/bonsai/bonsai/bim/import_ifc.py | 11 ++++++++--- src/bonsai/bonsai/tool/drawing.py | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index 4285b6eae0..f0e76f6aaa 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -1136,7 +1136,7 @@ class IfcImporter: bpy.ops.view3d.view_selected() bpy.ops.object.select_all(action="DESELECT") - def setup_arrays(self, elements: Optional[set[ifcopenshell.entity_instance]] = None): + def setup_arrays(self, annotations_to_import: Optional[set[ifcopenshell.entity_instance]] = None) -> None: for pset in self.file.by_type("IfcPropertySet"): if pset.Name != "BBIM_Array": continue @@ -1144,10 +1144,15 @@ class IfcImporter: continue data = json.loads(data) for rel in pset.DefinesOccurrence: + element: ifcopenshell.entity_instance for element in rel.RelatedObjects: - if element.is_a("IfcAnnotation"): + if annotations_to_import is None: # IfcAnnotations are not loaded during base import. - continue + if element.is_a("IfcAnnotation"): + continue + else: + if element not in annotations_to_import: + continue for i in range(len(data)): tool.Blender.Modifier.Array.set_children_lock_state(element, i, True) tool.Blender.Modifier.Array.constrain_children_to_parent(element) diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 135ce99314..a1a70ae7d8 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -742,6 +742,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) for obj in ifc_importer.added_data.values(): tool.Collector.assign(obj)