mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
copy_representation now properly copies explicitly assigned IfcStyledItems
This commit is contained in:
committed by
Ryan Schultz
parent
0b7f798c03
commit
01a5e457a2
@@ -55,9 +55,9 @@ def copy_class(
|
||||
geometry.copy_data_links(data, copied_entities)
|
||||
geometry.change_object_data(obj, data, is_global=True)
|
||||
geometry.rename_object(data, geometry.get_representation_name(ifc.get_entity(data)))
|
||||
# Only assign styles if element doesn't get them from material
|
||||
if not root.has_material_styles(new):
|
||||
root.assign_body_styles(new, obj)
|
||||
# not sure what the purpose of this is, but removing it fixes wrong IfcStyledItems being assigned to
|
||||
# a duplicated object. Instead, copy_representation now properly copies IfcStyledItems directly.
|
||||
# root.assign_body_styles(new, obj)
|
||||
collector.assign(obj)
|
||||
return new
|
||||
|
||||
|
||||
@@ -111,6 +111,14 @@ class Root(bonsai.core.tool.Root):
|
||||
exclude_callback=exclude_callback,
|
||||
copied_entities=copied_entities,
|
||||
)
|
||||
|
||||
for representation in source.Representation.Representations:
|
||||
for item in representation.Items:
|
||||
if item.StyledByItem:
|
||||
for styled_by in item.StyledByItem:
|
||||
new_styled_by = ifcopenshell.util.element.copy(tool.Ifc.get(), styled_by)
|
||||
new_styled_by.Item = copied_entities[styled_by.Item.id()]
|
||||
copied_entities[styled_by.id()] = new_styled_by
|
||||
|
||||
elif dest.is_a("IfcTypeProduct"):
|
||||
if not source.RepresentationMaps:
|
||||
@@ -134,6 +142,13 @@ class Root(bonsai.core.tool.Root):
|
||||
exclude_callback=exclude_callback,
|
||||
copied_entities=copied_entities,
|
||||
)
|
||||
|
||||
for item in map.MappedRepresentation.Items:
|
||||
if item.StyledByItem:
|
||||
for styled_by in item.StyledByItem:
|
||||
new_styled_by = ifcopenshell.util.element.copy(tool.Ifc.get(), styled_by)
|
||||
new_styled_by.Item = copied_entities[styled_by.Item.id()]
|
||||
copied_entities[styled_by.id()] = new_styled_by
|
||||
|
||||
new_representation_maps.append(new_map)
|
||||
dest.RepresentationMaps = new_representation_maps
|
||||
|
||||
Reference in New Issue
Block a user