import bpy
#make shader for leaves
for material in bpy.data.materials:
if 'Leaves' in str(material):
nodes = material.node_tree.nodes
links = material.node_tree.links
#clear the links and add nodes
links.clear()
image1 = nodes.get(type= 'ShaderNodeTexImage')
princi = nodes.get(type= 'ShaderNodeBsdfPrincipled')
output = nodes.get(type='ShaderNodeOutputMaterial')
mixsha = nodes.new(type='ShaderNodeMixShader')
hueSa1 = nodes.new(type='ShaderNodeHueSaturation')
hueSa2 = nodes.new(type='ShaderNodeHueSaturation')
trnslu = nodes.new(type='ShaderNodeBsdfTranslucent')
colRam = nodes.new(type='ColorRamp')
mapran = nodes.new(type='ShaderNodeMapRange')
addsha = nodes.new(type='ShaderNodeAddShader')
#link all nodes
links.new(princi.outputs[0], addsha.inputs[1])
links.new(addsha.outputs[0], output.inputs[0])
links.new(trnslu.outputs[0], addsha.inputs[0])
links.new(hueSa1.outputs[0], trnslu.inputs[0])
links.new(hueSa2.outputs[0], hueSa1.inputs[4])
links.new(mapran.outputs[0], princi.inputs[9])
links.new(colRam.outputs[0], mapran.inputs[0])
links.new(image1.outputs[1], princi.inputs[21])
links.new(image1.outputs[0], hueSa2.inputs[4])
links.new(image1.outputs[0], colRam.inputs[0])
#Add different values for each object
princi.inputs[7].default_value = 0.1
hueSa1.inputs[3].default_value = 0.8
hueSa2.inputs[3].default_value = 0.9
mapran.inputs[3].default_value = 0.2
mapran.inputs[4].default_val
I'm trying to add nodes, link nodes to all materials that has "Leaves" in their name at the same time. It says the script has been executed but I don't see any changes to the materials.
If anyone could help me it would be great :)