mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
append_asset - check unique styles based on their name #6269
This commit is contained in:
@@ -525,6 +525,7 @@ class Usecase:
|
||||
if added_element := reuse_identities.get(element_identity):
|
||||
return added_element
|
||||
|
||||
ifc_class = element.is_a()
|
||||
attributes_ = None
|
||||
|
||||
def get_attributes() -> tuple[W.attribute, ...]:
|
||||
@@ -550,6 +551,13 @@ class Usecase:
|
||||
if existing_material is not None:
|
||||
reuse_identities[element_identity] = existing_material
|
||||
return existing_material
|
||||
elif element.is_a("IfcPresentationStyle"):
|
||||
style_name = element.Name
|
||||
if style_name is not None:
|
||||
existing_style = next((e for e in ifc_file.by_type(ifc_class) if e.Name == style_name), None)
|
||||
if existing_style is not None:
|
||||
reuse_identities[element_identity] = existing_style
|
||||
return existing_style
|
||||
|
||||
attrs = {}
|
||||
|
||||
@@ -598,7 +606,7 @@ class Usecase:
|
||||
attrs[attr_index] = attr_value
|
||||
|
||||
# Adding entity at the end just to keep it consistent with `file.add`.
|
||||
new = ifc_file.create_entity(element.is_a())
|
||||
new = ifc_file.create_entity(ifc_class)
|
||||
reuse_identities[element_identity] = new
|
||||
for attr_index, attr_value in attrs.items():
|
||||
new[attr_index] = attr_value
|
||||
|
||||
Reference in New Issue
Block a user