How can I delete a large amount of Materials? So I am doing renders of SolidWorks models in Blender. The models themselves do not pose a problem for me, however I have noticed that when the materials tab, to be precise the list of materials is opened Blender slows down almost to a stop until I reload the current .blend file.



This is from one of the models I have already setup and rendered. In the actual model I've cleaned up all those materials and setup my own which number 15-20. In spite of this these materials still remain in my file and slow down my work.

I have tried using the delete addon I've seen in some answers to this question but that only leads to Blender crashing. Manually removing them with the "Minus" is out of the question, I've done it before for single instances. Having 3-4 models with 5000-6000 materials is not timewise efficient.

Some extra info how I've setup the materials - ctrl+L Making material links to objects having the same material type.
There are two ways to approach this problem. There's a tedious easy one, and there's a programmatic complex one.

The tedious answer has been alluded to in the existing answer and a couple of comments. I.e. Blender is designed to delete (skip saving) any "orphaned" data block, like a material, anytime you save a scene. Consequently, if you remove those materials from any objects so that they're not being used by anything, then when you close Blender and reopen the scene, they should no longer be there. There is a way, though, to force Blender to keep an unused data block, by giving it a "Fake user" by clicking the 'F' next to its name in the object tab. This makes the data block seem used, so that it doesn't get deleted when Blender closes. The solution is to (tediously) remove all of those materials from any object that's using them. Then close the scene.

The programmatic solution is to write a Python script which will do a lot of this for you. Depending on what your objective is, you might have the script look at each material, find the object(s) it's assigned to, and replace the duplicate material with some other material, so that all your objects are using the same material. There are other ways to approach the design, depending on what your goals are, but all of them should be relatively simple. For example, this script is very short, and does some things sort of similar to what you're trying to do to... maybe.

I hope that helps.