geometry.edit_object_placement was producing orphaned placements

It was producing orphaned IfcLocalPlacement if placement was parent to some other one. During edit_object_placement we were replacing all parent references with the new placement but wasn't removing the old one.
This commit is contained in:
Andrej730
2023-08-16 10:48:42 +05:00
parent 4f7564e5ae
commit 5481237480
2 changed files with 36 additions and 61 deletions
@@ -49,15 +49,14 @@ class Usecase:
old_placement = self.settings["product"].ObjectPlacement
if old_placement:
inverses = self.file.get_inverse(old_placement)
if len(inverses) == 1:
for inverse in self.file.get_inverse(old_placement):
if inverse.is_a("IfcLocalPlacement"):
ifcopenshell.util.element.replace_attribute(inverse, old_placement, new_placement)
if self.file.get_total_inverses(old_placement) == 1:
self.settings["product"].ObjectPlacement = None
old_placement.PlacementRelTo = None
ifcopenshell.util.element.remove_deep2(self.file, old_placement)
else:
for inverse in inverses:
if inverse.is_a("IfcLocalPlacement"):
ifcopenshell.util.element.replace_attribute(inverse, old_placement, new_placement)
ifcopenshell.util.element.remove_deep(self.file, old_placement)
new_placement.PlacementRelTo = placement_rel_to
self.settings["product"].ObjectPlacement = new_placement
@@ -97,7 +96,6 @@ class Usecase:
elif getattr(self.settings["product"], "ContainedInStructure", None):
return self.settings["product"].ContainedInStructure[0].RelatingStructure.ObjectPlacement
def get_children_settings(self, placement):
if not placement:
return []