2
$\begingroup$

I'm importing a FBX sequence from Anima Pro with several animated characters but all materials are interpreted as metallic. Every time I import a new fbx I have to manually change hundreds of materials and setting the metallic property to 0.

Is there a way to automatically change the properties of multiple materials on multiple objects?

Can this be done in a script?

$\endgroup$
5
$\begingroup$

Try this. It affects all materials in the file.

import bpy
for mat in bpy.data.materials:
    if not mat.use_nodes:
        mat.metallic = 0
        continue
    for n in mat.node_tree.nodes:
        if n.type == 'BSDF_PRINCIPLED':
            n.inputs["Metallic"].default_value = 0
$\endgroup$
0
2
$\begingroup$

thanks @scurest I managed to apply this only to the selected objects:

import bpy
for obj in bpy.context.selected_objects:
    for mat in obj.data.materials:
        if not mat.use_nodes:
            mat.metallic = 0
            continue
        for n in mat.node_tree.nodes:
            if n.type == 'BSDF_PRINCIPLED':
                n.inputs["Metallic"].default_value = 0
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.