Hello, is there a way to mute all image texture nodes in scene through python ?
for mat in bpy.data.materials:
if mat.use_nodes:
nodes = mat.node_tree.nodes
tex_nodes=[n for n in nodes if n.bl_idname=='ShaderNodeTexImage']
for node in tex_nodes:
node.mute=True
2 Likes
Any reason for doing the ShaderNodeTexImage
check and mute operations in two for loops instead of one? e.g.:
for mat in bpy.data.materials:
if mat.use_nodes:
for node in mat.node_tree.nodes:
if node.bl_idname == 'ShaderNodeTexImage':
node.mute = True
No reason, yours is clean and simple.
I just like to use arrays in case I need to reuse them later.
1 Like
In general, one would expect the list comprehension to be faster than the for loop. But I have not tested this particular case.