objects.material
MAXScript - Get object's material ID
Hi,
I'm trying to get an object's material ID, but all I can find is info on getting the individual face material ID's (which don't seem to make sense either, if I have only one material in the scene and one object, the MatID's are all different).
I can access the properties of the object's material with the following:
All I want is it's ID number though. Any ideas?
"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2
A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk
I'll move this over to the Visual Arts forum, where far more Max people hang out, I expect.
If anyone's interested, it was partially solved by accepting the first face's material ID as the best guess of the whole object's material.
I'd still appreciate a proper solution if anyone has one.
--Current object as a meshObjMesh = snapshotAsMesh objects--Get material ID of the first faceMatID_Face1 = getFaceMatID ObjMesh 1 --get material ID using modulusMatID = mod MatID_Face1 sceneMaterials.count
I'd still appreciate a proper solution if anyone has one.
"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2
A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk
An entire mesh doesn't have a material ID, each face does. We can say an object has a material ID of 13, if every face in the object has a material ID of 13. Otherwise, if it is split up between various groups, the 'object' no longer has a single material ID, does it? So your solution is really the right one.
Unless you mean you want to find what slot in the material editor a material is?
If so (not an elegant solution but it should work), you can get:
objMatName = objects.mat.name
for i in 1 to 24 do ( --remember than meditmaterials can only have 24 materials
if meditmaterials.name == objMatName then print i
)
You can also substitute sceneMaterials for meditmaterials with:
for i in 1 to sceneMaterials.count do (
*as above*
So, if you want to find the material ID for geo, you have the right technique, if you want to find the material editor slot, try what I've stated above.
Unless you mean you want to find what slot in the material editor a material is?
If so (not an elegant solution but it should work), you can get:
objMatName = objects.mat.name
for i in 1 to 24 do ( --remember than meditmaterials can only have 24 materials
if meditmaterials.name == objMatName then print i
)
You can also substitute sceneMaterials for meditmaterials with:
for i in 1 to sceneMaterials.count do (
*as above*
So, if you want to find the material ID for geo, you have the right technique, if you want to find the material editor slot, try what I've stated above.
-------------www.robg3d.com
Quote: Original post by Professor420
So, if you want to find the material ID for geo, you have the right technique
Thanks, and it does make sense.
I simply assumed an object might have a material, since this is the way it is loaded from a .3DS file.
"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2
A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement