• 13
• 14
• 27
• 9
• 9

# Material ID Help

This topic is 3873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have this code in MaxScript for reading a faces material ID:
for f = 1 to NumFaces do
(
index = getFaceMatID Mesh f
format "%\n" index to:out_file
)

I only have 1 map applied to the object but when i run the script a get all sorts of values between 1 and 6. this is the output: 2 2 1 1 5 5 4 4 6 6 3 3 Any ideas why? [Edited by - hahaha on August 5, 2007 6:14:33 AM]

##### Share on other sites
Never done any Max Script and it's around 8 years since I last wrote a Max plugin that had to deal with materials.

That said I do have a vague recollection that you had to do something along the lines of "materialID = materialID % numberOfMaterials" if the materialID you got for the face was out of range. That worked for all sorts of fun combinations of multi-sub.

I think the samples in the SDK do that too.

If the modulo operator doesn't fix it, reposting your question on Sparks is probably a good idea.

##### Share on other sites
Thanks i tried using the modulo operator but there is no such operator in MaxScript. I posted the same question at sparks.

##### Share on other sites
Quote:
 Original post by hahahabut there is no such operator in MaxScript.

Google for maxscript+modulo points me at:

http://www.scriptspot.com/bobo/mel2mxs/arithmetic.htm

Quote:
 In MAXScript, the modulus operation is performed using the mod function, followed by the two arguments. The result of the mod function in MXS is always a Float:card = mod 7 3 --result is 1.0bus = mod 0.5 3 --result is 0.5