Q: Highest material ID in object

Hi, it's me again :)
I have one quick question; is there any fast way to get highest material ID in some object?
For example:
I have multisub material with 20 materials inside. That material is assigned to object witch uses (for example) 15 of those materials, but not in order; they are randomly distributed, and maybe ID 20 is not used on that object, so highest ID can even be 5 on that object.
So, I want to know what is highest material ID used on selected object, so that I can limit my script to that number.

That's all for now ;)

P.S. Object can even be without material, but it can have assigned materials ID's that can be for example like this: 1,2,5,8,14,22,33 And I will like to get that last number as value (33).

Comments

Comment viewing options

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

works on mesh

amax(for i=1 to $.numFaces collect getFaceMatID $ i)

my recent MAXScripts RSS (archive here)

koberko's picture

Tnx for this! I will try it

Tnx for this! I will try it later today (I have some more urgent stuff to do).

Comment viewing options

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