From b5bc53bdf66cbdf6944e3d8096fd5aa1e28019b9 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 11 Apr 2025 12:58:30 +0500 Subject: [PATCH] Renaming style from UI not to add .xxx Blender suffix to style name Set style name explicitly, this way what user does in UI is what they get in IFC. Previously confusingly if you set style name to "Glass" and "Glass" already existed, you would get "Glass.001" style internally but "Glass" name in UI. --- src/bonsai/bonsai/tool/style.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/tool/style.py b/src/bonsai/bonsai/tool/style.py index 79f3131715..bf124e23a2 100644 --- a/src/bonsai/bonsai/tool/style.py +++ b/src/bonsai/bonsai/tool/style.py @@ -666,9 +666,12 @@ class Style(bonsai.core.tool.Style): @classmethod def rename_style(cls, style: ifcopenshell.entity_instance, name: str) -> None: """Rename style and related blender material.""" + if style.Name == name: + return + style.Name = name blender_material = tool.Ifc.get_object(style) - # Will implicitly update the style name using handler. - blender_material.name = name + assert isinstance(blender_material, bpy.types.Material) + tool.Root.set_material_name(blender_material, name) @classmethod def purge_unused_styles(cls) -> int: