Fix error loading external shader styles

Mentioned in logs from #5820
Turned out, `area.spaces` also contain all other spaces this area used (e.g. it used be view3d before it became a nodegraph) leading to errors. Simplifying it with `area.spaces.active`.
This commit is contained in:
Andrej730
2024-12-04 16:58:13 +05:00
parent 00a509aa0b
commit bb441ade3f
+5 -4
View File
@@ -323,10 +323,11 @@ class Blender(bonsai.core.tool.Blender):
for screen in bpy.data.screens:
for area in screen.areas:
if area.type == "NODE_EDITOR":
for space in area.spaces:
if space.tree_type == "ShaderNodeTree":
context_override = {"area": area, "space": space, "screen": screen}
return context_override
space = area.spaces.active
assert isinstance(space, bpy.types.SpaceNodeEditor)
if space.tree_type == "ShaderNodeTree":
context_override = {"area": area, "space": space, "screen": screen}
return context_override
@classmethod
def copy_node_graph(cls, material_to: bpy.types.Material, material_from: bpy.types.Material) -> None: