ScriptSpot

Forum topic · Scripts Wanted

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

By sampei · 2020-09-02

Description

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 (2)

Swordslayer · 2020-10-23

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] = ""

sampei · 2021-01-24

works like a charm, thanks very much!