mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Fix #3974. Bug where orphaned histories would be left in API remove operations.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
@@ -115,7 +116,10 @@ class Usecase:
|
||||
nests.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": nests})
|
||||
else:
|
||||
history = nests.OwnerHistory
|
||||
self.file.remove(nests)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
|
||||
if is_nested_by:
|
||||
related_objects = list(is_nested_by.RelatedObjects)
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, item=None, new_parent=None):
|
||||
@@ -35,5 +37,13 @@ class Usecase:
|
||||
nests.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": nests})
|
||||
else:
|
||||
history = nests.OwnerHistory
|
||||
self.file.remove(nests)
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_object=self.settings["item"], relating_object=self.settings["new_parent"])
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object",
|
||||
self.file,
|
||||
related_object=self.settings["item"],
|
||||
relating_object=self.settings["new_parent"],
|
||||
)
|
||||
|
||||
@@ -18,17 +18,18 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, related_object=None):
|
||||
"""Unassigns a related_object from its nest.
|
||||
|
||||
|
||||
An object (the whole within a decomposition) is Nested by zero or one more smaller objects.
|
||||
This function will remove this nesting relationship.
|
||||
|
||||
|
||||
If the object is not part of a nesting relationship, nothing will happen.
|
||||
|
||||
|
||||
:param related_object: The child of the nesting relationship, typically
|
||||
an IfcElement.
|
||||
:type related_object: ifcopenshell.entity_instance.entity_instance
|
||||
@@ -56,11 +57,13 @@ class Usecase:
|
||||
if not rel.is_a("IfcRelNests"):
|
||||
continue
|
||||
if len(rel.RelatedObjects) == 1:
|
||||
return self.file.remove(rel)
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
return
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(self.settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run(
|
||||
"owner.update_owner_history", self.file, **{"element": rel}
|
||||
)
|
||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
Reference in New Issue
Block a user