Delete all materials in scene except selected

Hey there,

all right, 1000th variation of the same.

I have a file with, say, 30 models, each consisting of 10 parts, each part has 10 materials of which I need one, in total 4, the same 4 for every model.

Material Utilities helps a bit, by merging base names, but always leaves a couple, and I’d still have to go through every part of every model to delete all but one assigned material.

How would you go about that? Is there no way in the outliner to see all materials used, batch select them and simply delete?

Change outliner mode to blender file and navigate into materials category:

You can shift click to select range or ctrl double click to deselect some materials and right click → delete them:

Note what it will leave empt material slots, but I think material utils addon also had a thing for mass empty slot deletion:

1 Like

Oh yes… after countless topics, posts etc. YOU are the solution.
I couldn’t figure out how to mass remove the empty slots, though… do I care?

I tried all sorts of things - remove all slots from one part, assign the 4 needed materials to that part, select all, link materials. Didn’t work, all that junk was STILL there!

If I find a solution for the empty slots, great, if not… well.

After some more investigating it seems that base blender “remove empty slots” option only works on single object:

image

And one added by material utils addon which is supposed to work on multiple objects gives error :frowning:

image

This probably should reported on bug tracker, or maybe someone else can help with alternative solution using python.

1 Like

How did you get the Material Utils context in the material lister?

I don’t get an error if I use “clean slots”, but it seems to mess stuff up by moving all empty slots to top and the only used material to bottom, so no cleanup…