fix duplicated ifcstyleditems using append_asset

since we don't use `file.add` to add inverse items and we use `file.create_entity` it was duplicating new elements, added optional parameter that makes it possible to track already added relationships between `append_asset`s.
This commit is contained in:
Andrej730
2024-03-05 12:13:22 +05:00
parent 9d71b7483f
commit 8c28f52e6a
3 changed files with 68 additions and 6 deletions
@@ -56,6 +56,7 @@ class Patcher:
self.aggregates = {}
self.new = ifcopenshell.file(schema=self.file.wrapped_data.schema)
self.owner_history = None
self.reuse_identities: dict[int, ifcopenshell.entity_instance] = {}
for owner_history in self.file.by_type("IfcOwnerHistory"):
self.owner_history = self.new.add(owner_history)
break
@@ -83,7 +84,9 @@ class Patcher:
pass
if element.is_a("IfcProject"):
return self.new.add(element)
return ifcopenshell.api.run("project.append_asset", self.new, library=self.file, element=element)
return ifcopenshell.api.run(
"project.append_asset", self.new, library=self.file, element=element, reuse_identities=self.reuse_identities
)
def add_decomposition_parents(self, element, new_element) -> None:
for rel in element.Decomposes: