mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 13:52:23 +00:00
Fix bug where removing objects could leave orphaned annotation relationships
This commit is contained in:
@@ -130,4 +130,9 @@ class Usecase:
|
|||||||
elif inverse.is_a("IfcRelAssignsToGroup"):
|
elif inverse.is_a("IfcRelAssignsToGroup"):
|
||||||
if len(inverse.RelatedObjects) == 1:
|
if len(inverse.RelatedObjects) == 1:
|
||||||
self.file.remove(inverse)
|
self.file.remove(inverse)
|
||||||
|
elif inverse.is_a("IfcRelAssignsToProduct"):
|
||||||
|
if inverse.RelatingProduct == self.settings["product"]:
|
||||||
|
self.file.remove(inverse)
|
||||||
|
elif len(inverse.RelatedObject) == 1:
|
||||||
|
self.file.remove(inverse)
|
||||||
self.file.remove(self.settings["product"])
|
self.file.remove(self.settings["product"])
|
||||||
|
|||||||
@@ -245,3 +245,10 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
|||||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
|
ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
|
||||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||||
assert not self.file.by_type("IfcRelAssignsToGroup")
|
assert not self.file.by_type("IfcRelAssignsToGroup")
|
||||||
|
|
||||||
|
def test_removing_product_assignments(self):
|
||||||
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
|
annotation = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcAnnotation")
|
||||||
|
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=element, related_object=annotation)
|
||||||
|
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||||
|
assert not self.file.by_type("IfcRelAssignsToProduct")
|
||||||
|
|||||||
Reference in New Issue
Block a user