Changing multiple shaders

I imported an FBX containing hundreds of models, each one having 6 shaders. They all get metallic at 50%, I need them at 0. Is it possible to write a script to change them all together, otherwise it will be impossible to manage.

import bpy
context = bpy.context

for ob in context.scene.objects:
    if ob.type in ('MESH', 'CURVE'):
        for slot in ob.material_slots:
            if slot.material.use_nodes:
                node_tree = slot.material.node_tree
                mat_output = node_tree.get_output_node('ALL')
                node = mat_output.inputs[0].links[0].from_node
                if node.name == "Principled BSDF":
                    node.inputs[4].default_value = 0

            slot.material.metallic = 0
1 Like

Thank you so much! This is so useful for me. :slight_smile:

1 Like