2
$\begingroup$

Im trying to go from node to node via the the output / input links of the shader graph node tree.

How do I receive the linked node from another nodes output?

for mat in bpy.data.materials:
    if mat.node_tree != None:
        for node in mat.node_tree.nodes:
            if type(node) is ShaderNodeUVMap and node.name == "UV4":
                #I want something like this
                print(node.outputs[0].link.node.name)
$\endgroup$
1

1 Answer 1

1
$\begingroup$

you can do it like this:

enter image description here

code:

import bpy

for mat in bpy.data.materials:
    if mat.node_tree != None:
        for node in mat.node_tree.nodes:
            
            if node.name ==  "Principled BSDF":
                #I want something like this
                print("name is:", node.outputs[0].links[0].to_node.name)

result: name is: Material Output

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .