Purge Unused Materials

2 votes
Version: 
1.1
Date Updated: 
02/19/2016

A simple macroscript to delete all unused materials from the Compact Editor Material Slots AND the Slate Material Editor Views.
The Compact Editor Code is from the existing Macro found under the Compact Material Editor "Utilities" menu.
I have added the code to also purge the SME at the same time.

You might want to check out the "Purge Empty Layers" macroscript as well. There are some awesome scene management tools out there but these are both small, simple tools without a lot of overhead for doing a little housekeeping before saving your file.

See the included README.txt for installation instructions.

Reminder, this is a macroscript for quick access from the UI.

Update ver. 1.1:
Fixes an error message when running the script without ever having opened the Slate Material Editor. Thanks to user appius for pointing out the bug.
To install: Remove the older macro and any UI references and then install this one following the same directions included in the README.txt inside the zip.

Version Requirement: 
3ds max 2011 - 2015

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
appius's picture

hi in max 2016, it delete all

hi
in max 2016, it delete all mat, even those applied to something.

thanulee's picture

Awesome if u make it full 2017 compatible

Very useful, plz update it, i didnt use it in big scenes yet so cant give feedback yet, in small test scenes it does the job :) thank u very much!!

Digital Animation Services's picture

delay with deleting unused materials

Hey madmax. Thanks for the inquiry. I have not seen this behavior before but I'll look into it. This is one of those scripts I don't use every day but I'm really happy it's there when I need it. Honestly, I don't think I've run it in 2017 if that's what you're using. Sorry to say, I'm still making the transition, even after all this time. To help me out, can I ask what release of max you're using? And also, do you have any third party plugins (Vray for example) installed that affect the Materials Editor? And of course, let me know if you happen to run any other trouble-shooting attempts and what results you get. Please note I've been abroad for the last 3 weeks, only returning home to my office on March 2 so I'm pretty swamped trying to catch up right now. I can't give this top priority at the moment but I'll do my best to get back to you ASAP. Thanks for your patience and of course, for trying my script!

David

madmax's picture

It works but actually takes time

Hi,

I tried this script with Slate Material Editor but the unused materials are deleted after the certain time only. (say 2 min).

According to my understanding, this is because gc is not invoked by the time I called the script. Further I tried the script by force calling gc() and freeSceneBitmaps() but still unused materials are not deleting by the time I needed.

Could you please advise?

Digital Animation Services's picture

SelectAll error fix

Thanks again for pointing out this error appius. I was able to run it down and update the script with a fix. I found I got this error if I ran the script without ever opening the Slate Material Editor even if I had been working in the Compact Editor. I hadn't thought of it since clearing the Compact Editor already has it's own menu option under the "Utilities" menu. Guess I was assuming you'd only really need my script if working in the Slate Editor, but obviously the script should work either way as described without the error. Thanks again! I will be uploading a link to the revised version ASAP.

David

Digital Animation Services's picture

SelectAll error

Sorry for the delay responding to your comment. Thanks for taking the time to let me know about the error. Can you tell me what version of Max you are using? That might help me narrow down the issue. I will look into this and post my findings. My colleagues and I have been using the script regularly in our work without this error, but I'll see what I can find out. Sorry for the problem.

David

appius's picture

error

got this error:

--Unknown property: "selectAll" in

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.