ScriptSpot

Forum topic · General Scripting

Q: Highest material ID in object

By koberko · 2011-07-30

Description

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

works on mesh

Anubis · 2011-07-30

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

koberko · 2011-08-01

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