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 SVGMat.820

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.)

  • 1
    $\begingroup$ An easier workaround for this problem might be to just join all objects with the same color in illustrator ahead of time. Selecting them and joining them in illustrator should be relatively easy, that way when imported you only get one single material. Separating them by loose parts in Blender should also be relatively easy if you do in fact need separate objects. $\endgroup$ Aug 2, 2022 at 9:30
  • 1
    $\begingroup$ Hum, not versed in illustrator myself. Try opening the svg in Inkscape and joining there, perhaps $\endgroup$ Aug 4, 2022 at 5:34
  • 1
    $\begingroup$ @DuarteFarrajotaRamos You convinced me to revisit Inkscape after quite some time, and I'm glad I did. Inkscape enabled me to accomplish what Illustrator could not. Steps: 1Go to Layer > Layers & Objects 2Create a layer for each color to keep paths in order. 3Select the topmost layer in the stack, then Edit > Select Same... Fill Color, and drag those selected paths into the topmost Layer. 4Repeat step 3, selecting the topmost path, but move to the next layer down. Do this for ea. color. 5For ea. Layer, select the range of all paths inside, then Path > Union 6Save As $\endgroup$
    – Mentalist
    Aug 4, 2022 at 10:00
  • 1
    $\begingroup$ Using other software is fine here if it solves the issue, as long as it focuses on a Blender related problem. You may also consider posting there as well for the Inkscape part at least, I'm not a frequent visitor there, so not sure about the on-topicness, but at least initially it seems fine. haven't used it much lately, but Inkscape matured quite well lately, especially the multi-page support. $\endgroup$ Aug 4, 2022 at 11:05
  • 1
    $\begingroup$ @DuarteFarrajotaRamos I've posted an answer - something a little more comprehensive than the explanation in my comment. :-) $\endgroup$
    – Mentalist
    Aug 5, 2022 at 1:18

1 Answer 1


Assuming you are starting with a muli-path trace result created with some vector design software such as Illustrator or Inkscape - here are the steps in Inkscape for consolidating and joining the paths of that artwork according to color:

1. Go to Layer > Layers & Objects. This gets the Layers panel to appear if it isn't already visible.

2. Create a layer for each color to keep paths in order. To make the result more intuitive, you can re-order the layers so that Layer 1, Layer 2, Layer 3, etc go from top-to-bottom instead of bottom-to-top.

Tip: You can re-order layers quickly by clicking the Up and Down arrow buttons at the top of the Layers panel.

3. Select the topmost path in the group, then Edit > Select Same > Fill Color, and drag those selected paths into the topmost layer. Aim carefully to drop into the layer, not above or below it.

The selected layers are now those which share the same color.

Tip: Once a layer contains something, a triangle icon appears to the left of it. You can use this to keep track of which layers you have already dragged paths into. It's a good idea to click this icon to collapse a layer to hide its contents after dragging paths into it.

Tip: If you have a solid color background in your trace result that you want to get rid of, now is the time to delete that path - before joining the paths by color.

4. Repeat step 3, selecting the topmost path, but move the selected paths to the next layer down. Do this for each path color / layer.

5. For each layer, select the range of all paths inside.

Note: I don't currently know of a way to select all paths in a layer in a single step, but you can select the top path and then Shift+Click the bottom path, and that whole range will be selected.

From the menu, choose Path > Union

After doing Union, rename the path to a number indicating its position in the stack.

Optional: You can drag each of these paths into a single layer to consolidate / organize. You can then delete any unused layers and groups.

6. You're done! Save As. This SVG is ready for import into Blender, and will now have a manageable number of paths, and materials to match.

Inkscape version used in this answer is 1.2.1 for Mac


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .