mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user