Fix bug where copying elements shared a placement. This fix speeds up copying parent elements in the decomposition significantly, like when copying a storey.

This commit is contained in:
Dion Moult
2021-10-14 16:13:48 +11:00
parent dd3fc79fb9
commit 199be3363f
2 changed files with 27 additions and 5 deletions
@@ -12,11 +12,14 @@ class Usecase:
def execute(self):
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(self.file.schema)
result = ifcopenshell.util.element.copy(self.file, self.settings["product"])
self.copy_direct_attributes(result)
self.copy_indirect_attributes(self.settings["product"], result)
# Copying representations is too hard, so for now we just don't do it.
self.remove_representations(result)
return result
def copy_direct_attributes(self, to_element):
self.remove_representations(to_element)
self.copy_object_placements(to_element)
def copy_indirect_attributes(self, from_element, to_element):
for inverse in self.file.get_inverse(from_element):
if inverse.is_a("IfcRelDefinesByProperties"):
@@ -46,3 +49,8 @@ class Usecase:
element.Representation = None
elif element.is_a("IfcTypeProduct"):
element.RepresentationMaps = None
def copy_object_placements(self, element):
if not element.is_a("IfcProduct") or not element.ObjectPlacement:
return
element.ObjectPlacement = ifcopenshell.util.element.copy(self.file, element.ObjectPlacement)