2
$\begingroup$

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.

Amount of materials in one of the models. Yes, they are ordered numerically.

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.

$\endgroup$
  • $\begingroup$ a good addon watch this video youtube.com/watch?v=hDjjBVDydzk hope it helps you $\endgroup$ – atek Aug 7 '17 at 7:48
  • $\begingroup$ So, you had like 6000 objects? Couldn't you perhaps join them first and then use just one material instead? One non optimal way to get rid of all those materials would perhaps be join all those objects now and export the joined single object to a format that could be later imported as bare mesh (not linked to existing materials) $\endgroup$ – m.ardito Aug 7 '17 at 8:46
  • $\begingroup$ The script here will delete all materials. $\endgroup$ – sambler Aug 7 '17 at 8:52
  • 1
    $\begingroup$ As far as I know, if no object is using those materials, they should disappear as soon as you save, close and re-open the file. Isn't this working properly? $\endgroup$ – Nicola Sap Aug 7 '17 at 8:57
  • 1
    $\begingroup$ That one will delete them all. Do you want to delete materials starting with "Shape" or keep ones starting with "MyMat"? $\endgroup$ – sambler Aug 7 '17 at 9:51
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ About the easy answer - They are already "orphaned". As much as I know when I do ctrl+L - Material Link them, the old materials are orphaned. I have checked for single instances - yes, when saved and reloaded the material in question e.g "Shape 0001" is deleted, however when selecting a higher number of objects th materials are not deleted. About the Python approach - I have to look into it. Thanks for the idea! $\endgroup$ – Bonorose Aug 8 '17 at 5:50
  • $\begingroup$ Interesting... I wonder if that's a bug? If you can make a small, reproducible example, I'd recommend making a bug report at graphicall.org $\endgroup$ – Matt Aug 8 '17 at 12:32
0
$\begingroup$

Please follow the steps to clean that

  1. Un link all materials form all objects, that do you want to get rid off
  2. Save your blender file
  3. Hit Ctr + Shift + O
  4. It will show you the recent menu, open your file again by selecting file name form menu

Before: enter image description here

After: enter image description here

$\endgroup$
  • $\begingroup$ I have been doing this and what it does help with is the slow after opening the materials tab. As I clarified above, in single object cases it does work, but SolidWorks provides extremely high poly models (I know I can downscale, however I can not affor to do it because of photorealism. Most of the models are NURBs based from SW). $\endgroup$ – Bonorose Aug 8 '17 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.