From 3c51c6325c3480e4ca8ffc33f8b42684246e84cc Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 8 Oct 2024 22:35:15 +1100 Subject: [PATCH] Fix #5515. Spaces are now special and have their own collection. Elements in a space don't go inside a space collection anymore. There can be hundreds of spaces in a building, and generally we use collections for bulk selections (i.e. at the floor level) not for spaces. --- src/bonsai/bonsai/tool/collector.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bonsai/bonsai/tool/collector.py b/src/bonsai/bonsai/tool/collector.py index e571e910cf..76aeb1483c 100644 --- a/src/bonsai/bonsai/tool/collector.py +++ b/src/bonsai/bonsai/tool/collector.py @@ -63,6 +63,9 @@ class Collector(bonsai.core.tool.Collector): elif element.is_a("IfcOpeningElement"): collection = cls._create_project_child_collection("IfcOpeningElement") cls.link_collection_object_safe(collection, obj) + elif element.is_a("IfcSpace"): + collection = cls._create_project_child_collection("IfcSpace") + cls.link_collection_object_safe(collection, obj) elif element.is_a("IfcStructuralItem"): collection = cls._create_project_child_collection("IfcStructuralItem") cls.link_collection_object_safe(collection, obj) @@ -102,6 +105,8 @@ class Collector(bonsai.core.tool.Collector): elif element.is_a("IfcAnnotation") and (drawing_obj := cls.get_annotation_drawing_obj(element)): cls.link_collection_object_safe(drawing_obj.BIMObjectProperties.collection, obj) elif container := ifcopenshell.util.element.get_container(element): + while container.is_a("IfcSpace"): + container = ifcopenshell.util.element.get_aggregate(container) container_obj = tool.Ifc.get_object(container) if not (collection := container_obj.BIMObjectProperties.collection): cls.assign(container_obj)