I am trying to automate changes to materials in a large scene with 200+ materials. Currently, each material has a diffuse node with a color. Some have attached Image Texture nodes. Some are Transparency instead of Diffuse.
I want to replace all of the Diffuse nodes with my own Group, so that I can easily change the shader setup of the whole scene. But I need to preserve their colors and textures.
I have a script from https://blender.stackexchange.com/questions/78879/update-all-materials-but-keep-their-color-and-textures that swaps the currently selected node with a new node from a list, while preserving attached nodes, and does it on all selected objects. So this lets me change the Diffuse node into my Group while preserving the attached Texture node. But when I do it, I lose my Diffuse color!
So what I need to fully solve this problem is to create an RGB node in each material with only a Diffuse node, copy the Diffuse node’s color, and then hook the RGB node into the diffuse node. Then when I swap the Diffuse for my group, it will still have the color connected. Any ideas on how to do this? Script or existing addons?