Script to clear unused Multi/Sub-Object Material ID name

I'm looking for a simple script to clear the name of a Material ID that is no longer being used as the destination for a material.

For example I have a material named "Plastic" which I plug into ID-1 of my Multi/Sub-Object material, and I name this ID "Plastic". If I unplug the "Plastic" material from ID-1, the ID is still named "Plastic". I want the ID-1 name field to be empty, since nothing is plugged into it.

Basically I want the script to erase the name of Material IDs when nothing is plugged into them.

Thanks in advance!

Comments

Comment viewing options

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

 

This will do that for all multimaterials in the scene:

mats = getClassInstances MultiMaterial
for mat in mats do for m = 1 to mat.materialIDList.count where mat.names[m].count > 0 and mat.materialList[m] == undefined do mat.names[m] = ""

Comment viewing options

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