Fix #2787. Fix creating invalid orphaned property and group relationships when removing systems / groups / elements.

This commit is contained in:
Dion Moult
2023-02-21 10:59:47 +11:00
parent 9d8551cb48
commit 03a66d2806
7 changed files with 118 additions and 5 deletions
@@ -25,3 +25,19 @@ class TestRemoveSystem(test.bootstrap.IFC4):
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
ifcopenshell.api.run("system.remove_system", self.file, system=system)
assert len(self.file.by_type("IfcSystem")) == 0
def test_removing_orphaned_group_relationships(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
ifcopenshell.api.run("system.assign_system", self.file, product=element, system=system)
ifcopenshell.api.run("system.remove_system", self.file, system=system)
assert not self.file.by_type("IfcRelAssignsToGroup")
def test_removing_orphaned_property_relationships(self):
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=system, name="Foo_Bar")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
ifcopenshell.api.run("system.remove_system", self.file, system=system)
assert not self.file.by_type("IfcRelDefinesByProperties")
assert not self.file.by_type("IfcPropertySet")
assert not self.file.by_type("IfcPropertySingleValue")