Removing an element now also purges connection relationships

This commit is contained in:
Dion Moult
2022-09-24 14:12:45 +10:00
parent 48eb6b70e3
commit 7545313dee
2 changed files with 13 additions and 0 deletions
@@ -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"])
@@ -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