acoolrocket

Blender - Copy BSDF base color to all material slots

Jan 18th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import bpy
  2.  
  3. base_color_hex = (0.01, 0.01, 0.01, 1.0) # RGBA values for 282828 in Blender
  4.  
  5. for obj in bpy.context.selected_objects:
  6. if obj.type == 'MESH':
  7. for slot in obj.material_slots:
  8. # Check if the material has a node tree
  9. if slot.material and slot.material.node_tree:
  10. principled_node = slot.material.node_tree.nodes.get("Principled BSDF")
  11.  
  12. if principled_node:
  13. # Set base color to 282828
  14. principled_node.inputs[0].default_value = base_color_hex
Add Comment
Please, Sign In to add comment