From 92cf0d9265a0b2ac7cf46a34814db6ac8e159325 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 22 Dec 2023 16:04:52 +0500 Subject: [PATCH] remove_representation not to leave brokens refs with batch_remove #4138 --- .../ifcopenshell/api/geometry/remove_representation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/remove_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/remove_representation.py index 7902e91b88..93f28a1f5a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/remove_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/remove_representation.py @@ -49,9 +49,10 @@ class Usecase: for texture in textures: ifcopenshell.util.element.remove_deep2(self.file, texture) + to_delete = getattr(self.file, "to_delete", ()) for element in styled_items: - if not element.Item: + if not element.Item or element.Item in to_delete: self.file.remove(element) for element in presentation_layer_assignments: - if len(element.AssignedItems) == 0: + if all(item in to_delete for item in element.AssignedITems): self.file.remove(element)