1
$\begingroup$

I have a bunch of metallic materials that use the Principled BDSF, and I need to change all of them from a metallic value of 10 to a metallic value of 1. Can this be done using a script?

$\endgroup$
3
  • $\begingroup$ Yes, it can, though I’m not sure how. Check out docs.blender.org for the main manual and the Python api docs. $\endgroup$
    – TheLabCat
    Commented Feb 21, 2021 at 20:49
  • 1
    $\begingroup$ PS: I did some code on GitHub.com that messes with shader nodes, though it does not do what you want. It might give you an idea of how the API works, though. github.com/thelabcat/SMD-Model-PostImport/blob/main/… $\endgroup$
    – TheLabCat
    Commented Feb 21, 2021 at 20:51
  • $\begingroup$ "metallic value of 10 to a metallic value of 1" I don't think this will have a visible effect. I think the metallic factor is just a lerp factor between "metal" and "nonmetal" and gets clamped to [0,1]. $\endgroup$
    – scurest
    Commented Feb 21, 2021 at 21:54

1 Answer 1

1
$\begingroup$

Shamelessly modified from:

Automatically change the properties of multiple materials

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

Not the answer you're looking for? Browse other questions tagged .