From 2d453492cc1059f998ad9258a222d9aedf62618f Mon Sep 17 00:00:00 2001 From: falken10vdl Date: Tue, 21 Jul 2026 09:58:06 +0200 Subject: [PATCH] Cache last shading type to skip redundant material style restores (cherry picked from commit c92a825a94824c2c1ea95556fb5057f7ccb78e16) --- src/bonsai/bonsai/tool/style.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bonsai/bonsai/tool/style.py b/src/bonsai/bonsai/tool/style.py index 47676637b8..2abcc4a5d9 100644 --- a/src/bonsai/bonsai/tool/style.py +++ b/src/bonsai/bonsai/tool/style.py @@ -1070,6 +1070,8 @@ class Style(bonsai.core.tool.Style): objects = [tool.Ifc.get_object(e) for e in elements] tool.Geometry.reload_representation(objects) + _last_shading_type: str | None = None + @classmethod def restore_material_style_types(cls, shading_type: str) -> bool: """Set each IFC material's active_style_type to the richest available for the given viewport mode. @@ -1080,6 +1082,10 @@ class Style(bonsai.core.tool.Style): Returns True if any IFC material has IfcSurfaceStyleWithTextures (used to decide color_type). """ + if cls._last_shading_type == shading_type: + return False + cls._last_shading_type = shading_type + has_any_textures = False for material in bpy.data.materials: if not tool.Blender.get_ifc_definition_id(material):