Why is the obtained material ID missing?

Why is the obtained material ID missing?

adamhahaEU2VH
Enthusiast Enthusiast
1,863 Views
7 Replies
Message 1 of 8

Why is the obtained material ID missing?

adamhahaEU2VH
Enthusiast
Enthusiast

I put all face material IDs in a list to remove duplicates, but there are missing ones

 

    ID=[]
    for i in range(1,rt.selection[0].numfaces):    #start from 1
        ID.append(rt.polyop.getfacematid(rt.selection[0],i))     #Add material ID to list
    ID=list(set(ID))    #"set" deduplication

 >>> ID

[1, 9, 15, 19, 20, 25]

However, when one of the special faces of the object is selected, its material ID actually shows 6.

adamhahaEU2VH_0-1650625451547.png

why?

 

(The sample has been uploaded.)

0 Likes
Accepted solutions (1)
1,864 Views
7 Replies
Replies (7)
Message 2 of 8

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

try maxscript :

ids = #{}
for i in $.faces as bitarray do append ids (polyop.getfacematid $ i)

the result ids:

#{1, 6, 9, 15, 19..20, 25}

so the id #6 is used. all is correct

Message 3 of 8

denisT.MaxDoctor
Advisor
Advisor

@adamhahaEU2VH wrote:

(The sample has been uploaded.)


Do you know how many users are using 3DS MAX 2022+ today? Post an example a couple of versions earlier than the recent, this will increase the chance that more people will look at it and respond.

0 Likes
Message 4 of 8

adamhahaEU2VH
Enthusiast
Enthusiast

Thank you, I tested it, but why is this happening? Is there a bug in the pymxs module?

0 Likes
Message 5 of 8

adamhahaEU2VH
Enthusiast
Enthusiast

I understand, next time I will save the earlier version as well.

0 Likes
Message 6 of 8

adamhahaEU2VH
Enthusiast
Enthusiast

>>> rt.selection[0].numfaces
1937

$.faces as bitarray
#{1..1937}

The number of faces obtained is the same.

0 Likes
Message 7 of 8

denisT.MaxDoctor
Advisor
Advisor

the face index is 1 based... so you are missing the last face.  

 

it should be:

 

 

for i in range(1,rt.selection[0].numfaces + 1):
...

 

 

Message 8 of 8

adamhahaEU2VH
Enthusiast
Enthusiast
Oh, it turns out that the range function will not go to the last one
Thanks again.
0 Likes