From cb9a7cf5bea24ab54480e93ecc4aa1a8eec2c40d Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 25 Jan 2023 17:42:27 +1100 Subject: [PATCH] Fix #2712. Handle deletion of rel services buildings. --- .../ifcopenshell/api/root/remove_product.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py index 50789f0dae..531deb8cca 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py @@ -76,11 +76,7 @@ class Usecase: ifcopenshell.api.run("grid.remove_grid_axis", self.file, axis=axis) # TODO: remove object placement and other relationships - - # Use a while loop so that we don't keep inverses in memory that might - # get deleted as a result of the API calls in the loop body (#2697) - while inverses := self.file.get_inverse(self.settings["product"]): - inverse = next(iter(inverses)) + for inverse in self.file.get_inverse(self.settings["product"]): if inverse.is_a("IfcRelDefinesByProperties"): ifcopenshell.api.run( "pset.remove_pset", @@ -102,6 +98,8 @@ class Usecase: self.file.remove(inverse) elif inverse.is_a("IfcRelVoidsElement"): self.file.remove(inverse) + elif inverse.is_a("IfcRelServicesBuildings"): + self.file.remove(inverse) elif inverse.is_a("IfcRelNests"): if inverse.RelatingObject == self.settings["product"]: for subelement in inverse.RelatedObjects: