From cd5d278353e4fb5290e7ebda0485bd65992cd389 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Thu, 26 Jan 2023 21:35:10 +0100 Subject: [PATCH] Magic UV: Get nodes with their types instead of names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using hardcoded names to retrieve nodes can result in errors if the user has enabled UI translation, because the new nodes may not have the expected English names. Instead, we retrieve the nodes using their types (BSDF_PRINCIPLED or OUTPUT_MATERIAL). Ref blender/blender#104145 --- magic_uv/op/texture_projection.py | 3 ++- magic_uv/op/uv_inspection.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/magic_uv/op/texture_projection.py b/magic_uv/op/texture_projection.py index cdd1e4b1b..45f02478b 100644 --- a/magic_uv/op/texture_projection.py +++ b/magic_uv/op/texture_projection.py @@ -449,7 +449,8 @@ class MUV_OT_TextureProjection_Project(bpy.types.Operator): # assign image if compat.check_version(2, 80, 0) >= 0: node_tree = obj.active_material.node_tree - output_node = node_tree.nodes["Material Output"] + output_node = next(n for n in node_tree.nodes + if n.type == "OUTPUT_MATERIAL") nodes = common.find_texture_nodes_from_material( obj.active_material) diff --git a/magic_uv/op/uv_inspection.py b/magic_uv/op/uv_inspection.py index dbd8e04d5..f72438752 100644 --- a/magic_uv/op/uv_inspection.py +++ b/magic_uv/op/uv_inspection.py @@ -447,7 +447,8 @@ class MUV_OT_UVInspection_PaintUVIsland(bpy.types.Operator): "MagicUV_PaintUVMaterial_{}".format(i)) if compat.check_version(2, 80, 0) >= 0: target_mtrl.use_nodes = True - output_node = target_mtrl.node_tree.nodes["Material Output"] + output_node = next(n for n in target_mtrl.node_tree.nodes + if n.type == "OUTPUT_MATERIAL") nodes_to_remove = [n for n in target_mtrl.node_tree.nodes if n != output_node] for n in nodes_to_remove: -- 2.30.2