mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
extended Root.copy_representation to also copy shape aspects
This commit is contained in:
committed by
Ryan Schultz
parent
d48f02a40b
commit
faf489e9dc
@@ -102,6 +102,26 @@ class Root(bonsai.core.tool.Root):
|
|||||||
exclude_callback=exclude_callback,
|
exclude_callback=exclude_callback,
|
||||||
copied_entities=copied_entities,
|
copied_entities=copied_entities,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if source.Representation.is_a("IfcProductDefinitionShape"):
|
||||||
|
old_to_new_items = {}
|
||||||
|
for repr_index, representation in enumerate(source.Representation.Representations):
|
||||||
|
for item_index, item in enumerate(representation.Items):
|
||||||
|
old_to_new_items[item.id()] = dest.Representation.Representations[repr_index].Items[item_index]
|
||||||
|
|
||||||
|
for aspect in source.Representation.HasShapeAspects:
|
||||||
|
new_reprs = []
|
||||||
|
for repr in aspect.ShapeRepresentations:
|
||||||
|
new_items = []
|
||||||
|
for old_item in repr.Items:
|
||||||
|
new_items.append(old_to_new_items[old_item.id()])
|
||||||
|
new_repr = ifcopenshell.util.element.copy(tool.Ifc.get(), repr)
|
||||||
|
new_repr.Items = new_items
|
||||||
|
new_reprs.append(new_repr)
|
||||||
|
new_aspect = ifcopenshell.util.element.copy(tool.Ifc.get(), aspect)
|
||||||
|
new_aspect.ShapeRepresentations = new_reprs
|
||||||
|
new_aspect.PartOfProductDefinitionShape = dest.Representation
|
||||||
|
|
||||||
elif dest.is_a("IfcTypeProduct"):
|
elif dest.is_a("IfcTypeProduct"):
|
||||||
if not source.RepresentationMaps:
|
if not source.RepresentationMaps:
|
||||||
return copied_entities
|
return copied_entities
|
||||||
|
|||||||
Reference in New Issue
Block a user