I would like to create a simple script that will change the values in selected "Value" nodes, but I cannot find information on how to access the list of selected nodes in the active material. I thought something like this would work, but I was wrong:

sel = bpy.context.scene.node_tree.nodes.active

Unfortunately, I have no idea how to fix it, so thank you for your help


1 Answer 1


You could just go through nodes and check if they are selected and if the type matches the one you need:

import bpy

nodes = bpy.data.materials["Material"].node_tree.nodes

for n in nodes:
    if n.select and n.type=="VALUE":
        n.outputs['Value'].default_value = 15

You can hit Tab in the Python console panel to use autocomplete function and find a lot of stuff about Blender's Python API:

enter image description here

  • $\begingroup$ Great, thank you very much :) $\endgroup$
    – Zyzio
    Nov 16, 2022 at 8:40

You must log in to answer this question.

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