From c311b65af52fd954d9e8ddd619bd07e4dcd37fb4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 20 Jan 2025 13:58:39 +1100 Subject: [PATCH] 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. --- src/bonsai/bonsai/bim/module/debug/operator.py | 4 ++-- src/bonsai/bonsai/tool/debug.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/debug/operator.py b/src/bonsai/bonsai/bim/module/debug/operator.py index e2cf537d07..6c7ddc2570 100644 --- a/src/bonsai/bonsai/bim/module/debug/operator.py +++ b/src/bonsai/bonsai/bim/module/debug/operator.py @@ -713,9 +713,9 @@ class MergeIdenticalObjects(bpy.types.Operator, tool.Ifc.Operator): return {"CANCELLED"} plural_object_type = f"{object_type.lower()}s" if merged_data: - print(f"Merged {plural_object_type}:") 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()) msg = " See system console for details." if merged else "" diff --git a/src/bonsai/bonsai/tool/debug.py b/src/bonsai/bonsai/tool/debug.py index 7f41927a8a..eb4dcd7df7 100644 --- a/src/bonsai/bonsai/tool/debug.py +++ b/src/bonsai/bonsai/tool/debug.py @@ -131,8 +131,8 @@ class Debug(bonsai.core.tool.Debug): # Calculate hashes. hash_to_elements: defaultdict[int, list[ifcopenshell.entity_instance]] = defaultdict(list) for element in elements: - # Ignore unnamed elements as they may be not safe to merge. - if not element.Name: + # Except for styles, ignore unnamed elements as they may be not safe to merge + if object_type != "STYLE" and not element.Name: continue element_hash = get_hash(element) hash_to_elements[element_hash].append(element)