Simply connect 2 Nodes with Python

Hi there
again, i don’t know what i’m doing…
the goal is to simply connect one or the other of these nodes inside the shader editor world context.
(obviously this script here does not work as intended at all)

You have to use the world tree specifically, not just the node_tree. See:

1 Like

thanks for pointing that out!

this is it:

import bpy

C = bpy.context
scn = C.scene

node_tree =
tree_nodes = node_tree.nodes

node_A = tree_nodes.get('b1')
node_output = tree_nodes.get('World Output')

links = node_tree.links
link =['Background'], node_output.inputs['Surface'])
1 Like