Hi !
I made lot’s of search but I can’t find how to delete all nodes in a list of materials,
My goal is for exemple to delete all existing node in materials with “Wood” in their name and then create a simple Diffuse BSDF linked with material output.
<b>for </b>mat <b>in </b>bpy.data.materials:
<b> if "Wood" in </b>mat.name:
<i><i>Delete all nodes
</i></i> ...
To get around this problem I had the idea to simply rename the materials with _old and replace them in their slots by a new one but I don’t like it
for mat in bpy.data.materials:
if "Wood" in mat.name:
nodes = mat.node_tree.nodes
for node in nodes:
if node.type != 'OUTPUT_MATERIAL': # skip the material output node as we'll need it later
nodes.remove(node)