I did an Image Trace in Adobe Illustrator and saved it as an SVG. The trace was restricted to a palette of just 6 colors. But upon importing into Blender, I end up with a separate material for each island, which in this case is hundreds of objects titled incrementally such as
Up to this point, whenever I imported SVG data into Blender, it was simpler geometry, maybe a logo or something. So I just replaced the default SVG import materials with my own, maybe sampling the hex colors where relevant, and throwing away the rest.
But this time I want to keep that palette of 6 colors and just modify the shader data (I mean send unique material colors from RGB Nodes into a shared Group Node containing the shader setup - do you follow?). Unfortunately Blender has no idea that some of those materials share a common color, while others do not. And I don't feel like pasting that Group Node into 820+ separate materials! lol
Is there a way this can be tackled using Python to loop through all materials named
SVGMat.* check if the Diffuse Color matches an existing material's Diffuse Color, and if it does, discard that redundant material in favor of the existing one?
(I feel like ideally the option to restrict materials to unique colors ought to be included as a setting of the SVG importer, possibly as default, but for now any kind of scripting workaround would be awesome.)