diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py index 705e8cbd73..0181924b47 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py @@ -70,4 +70,6 @@ class Usecase: elif inverse.is_a("IfcRelContainedInSpatialStructure"): if inverse.RelatingStructure == self.settings["product"] or len(inverse.RelatedElements) == 1: self.file.remove(inverse) + elif inverse.is_a("IfcRelConnectsPathElements"): + self.file.remove(inverse) self.file.remove(self.settings["product"]) diff --git a/src/ifcopenshell-python/test/api/root/test_remove_product.py b/src/ifcopenshell-python/test/api/root/test_remove_product.py index b922e72936..e30ca2a1d4 100644 --- a/src/ifcopenshell-python/test/api/root/test_remove_product.py +++ b/src/ifcopenshell-python/test/api/root/test_remove_product.py @@ -184,3 +184,14 @@ class TestRemoveProduct(test.bootstrap.IFC4): assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0 assert len(self.file.by_type("IfcSpace")) == 1 assert len(self.file.by_type("IfcWall")) == 0 + + def test_removing_path_connection_relationships_of_an_element(self): + element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam") + element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcColumn") + ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=element1, related_element=element2) + total_entities = len(list(self.file)) + ifcopenshell.api.run("root.remove_product", self.file, product=element1) + assert len(list(self.file)) == total_entities - 2 + assert len(self.file.by_type("IfcRelConnectsPathElements")) == 0 + assert len(self.file.by_type("IfcColumn")) == 1 + assert len(self.file.by_type("IfcBeam")) == 0