I wanted to change the value of Shader Node in Blender from the Python side, but it was unexpectedly annoying, so I made a note.
Blender2.81 Windows10
Access the shader value like this. Blender is an amateur of Zub, so if you have any details, please comment.
import bpy
mat = bpy.data.materials[mat_name] # get material
node_tree = mat.node_tree # node tree of material
nodes = node_tree.nodes # nodes array of material
bsdf = nodes.get("Principled BSDF") # get shader node you want
bsdf.inputs['Metallic'].default_value = 1.0 # set value to inputs
bsdf.inputs['Roughness'].default_value = 0.0
Recommended Posts