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?
Asked
Active
Viewed 958 times
1
-
Yes, it can, though I’m not sure how. Check out docs.blender.org for the main manual and the Python api docs. – TheLabCat Feb 21 '21 at 20:49
-
1PS: 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. https://github.com/thelabcat/SMD-Model-PostImport/blob/main/SMD_material_setup.py – TheLabCat Feb 21 '21 at 20:51
-
"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]. – scurest Feb 21 '21 at 21:54
1 Answers
1
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