diff --git a/src/bonsai/bonsai/bim/module/aggregate/operator.py b/src/bonsai/bonsai/bim/module/aggregate/operator.py index 5fa6885335..e94199b208 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/operator.py +++ b/src/bonsai/bonsai/bim/module/aggregate/operator.py @@ -127,6 +127,10 @@ class BIM_OT_aggregate_unassign_object(bpy.types.Operator, tool.Ifc.Operator): # Second pass: delete aggregates that now have no parts deleted_aggregates = [] for aggregate in aggregates_to_check: + # Skip spatial elements - they should not be deleted even if empty + if aggregate.is_a("IfcSpatialElement"): + continue + related_objects = ifcopenshell.util.element.get_parts(aggregate) if len(related_objects) == 0: aggregate_name = aggregate.Name or f"{aggregate.is_a()} #{aggregate.id()}" diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index a27849da31..903473b1b6 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -975,6 +975,10 @@ class OverrideDelete(bpy.types.Operator): except: continue + # Skip spatial elements - they should not be deleted even if empty + if aggregate.is_a("IfcSpatialElement"): + continue + related_objects = ifcopenshell.util.element.get_parts(aggregate) if len(related_objects) == 0: aggregate_name = aggregate.Name or f"{aggregate.is_a()} #{aggregate.id()}"