mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
See #5799. Allow merging unnamed styles.
Styles are special because their names aren't critically semantic. It's more to do with the style definition.
This commit is contained in:
@@ -713,9 +713,9 @@ class MergeIdenticalObjects(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
plural_object_type = f"{object_type.lower()}s"
|
plural_object_type = f"{object_type.lower()}s"
|
||||||
if merged_data:
|
if merged_data:
|
||||||
print(f"Merged {plural_object_type}:")
|
|
||||||
for element_type, element_names in merged_data.items():
|
for element_type, element_names in merged_data.items():
|
||||||
print(f"- {element_type}: {', '.join(element_names)}")
|
names = ", ". join([n or "Unnamed" for n in element_names])
|
||||||
|
print(f"- {element_type}: {names}")
|
||||||
merged = sum(len(v) for v in merged_data.values())
|
merged = sum(len(v) for v in merged_data.values())
|
||||||
|
|
||||||
msg = " See system console for details." if merged else ""
|
msg = " See system console for details." if merged else ""
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ class Debug(bonsai.core.tool.Debug):
|
|||||||
# Calculate hashes.
|
# Calculate hashes.
|
||||||
hash_to_elements: defaultdict[int, list[ifcopenshell.entity_instance]] = defaultdict(list)
|
hash_to_elements: defaultdict[int, list[ifcopenshell.entity_instance]] = defaultdict(list)
|
||||||
for element in elements:
|
for element in elements:
|
||||||
# Ignore unnamed elements as they may be not safe to merge.
|
# Except for styles, ignore unnamed elements as they may be not safe to merge
|
||||||
if not element.Name:
|
if object_type != "STYLE" and not element.Name:
|
||||||
continue
|
continue
|
||||||
element_hash = get_hash(element)
|
element_hash = get_hash(element)
|
||||||
hash_to_elements[element_hash].append(element)
|
hash_to_elements[element_hash].append(element)
|
||||||
|
|||||||
Reference in New Issue
Block a user