mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +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.copy_data_links(data, copied_entities)
|
||||||
geometry.change_object_data(obj, data, is_global=True)
|
geometry.change_object_data(obj, data, is_global=True)
|
||||||
geometry.rename_object(data, geometry.get_representation_name(ifc.get_entity(data)))
|
geometry.rename_object(data, geometry.get_representation_name(ifc.get_entity(data)))
|
||||||
# Only assign styles if element doesn't get them from material
|
# not sure what the purpose of this is, but removing it fixes wrong IfcStyledItems being assigned to
|
||||||
if not root.has_material_styles(new):
|
# a duplicated object. Instead, copy_representation now properly copies IfcStyledItems directly.
|
||||||
root.assign_body_styles(new, obj)
|
# root.assign_body_styles(new, obj)
|
||||||
collector.assign(obj)
|
collector.assign(obj)
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,14 @@ class Root(bonsai.core.tool.Root):
|
|||||||
copied_entities=copied_entities,
|
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"):
|
elif dest.is_a("IfcTypeProduct"):
|
||||||
if not source.RepresentationMaps:
|
if not source.RepresentationMaps:
|
||||||
return copied_entities
|
return copied_entities
|
||||||
@@ -135,6 +143,13 @@ class Root(bonsai.core.tool.Root):
|
|||||||
copied_entities=copied_entities,
|
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)
|
new_representation_maps.append(new_map)
|
||||||
dest.RepresentationMaps = new_representation_maps
|
dest.RepresentationMaps = new_representation_maps
|
||||||
return copied_entities
|
return copied_entities
|
||||||
|
|||||||
Reference in New Issue
Block a user