Does anybody know how to link the viewport colour with the actual diffuse colour, as it is with Blender internal.
if your material uses more than one diffuse shader… then which color should the viewport display?
What happens if the material doesnt have any diffuse shaders?
This little script will go through all materials in your file and set viewport color of it to the input color of one of the Diffuse BSDF nodes.
If there are more than one Diffuse nodes - it will pick one of them. If there’s no Diffuse node - it will leave viewport color unchanged.
import bpy
for mat in [m for m in bpy.data.materials if m.node_tree]:
for node in mat.node_tree.nodes:
if node.type == 'BSDF_DIFFUSE':
for i in range(3):
mat.diffuse_color[i] = node.inputs[0].default_value[i]
break
Bartekskorupa Thankyou so much sir! I knew i could not be the only one who needed this cycles solution.