PDA

View Full Version : 1 box... more than one material ID's assigned... how to find its submaterial names


abyjoe
07-24-2007, 07:57 PM
i have a box (editable poly) with a multisub material assigned to it.

and I am trying to use the $.material.name property but it gives me the multisub name and i cant find out what sub-material are assigned to the box...

and the box can have more than one sub-materials assigned to it... how can i find out?

Dave Black
07-24-2007, 08:04 PM
for i in $.material do print i.name


The multisub material stores the nested materials as an array.

--Edit:

If you have nested multisubs you will have to find the names recusivly.

-Dave

abyjoe
07-24-2007, 08:32 PM
thanks for replying dave... we definitely get all the the names but what i want is only the name of ths sub-material that is assigned to the box... and it can have more than 1 sub-materials assigned to it

so out of say 13 sub-materials the box can have 1 or 2,3... sub-materials assigned to it but not all

PiXeL_MoNKeY
07-24-2007, 09:01 PM
Basically you need to get the material ids being used by the object as an array. Then use the array values as the submaterial index. Then print the name of the said materials. You could use these functions to get something similar.
function faceCount obj = (
if (classof obj == PolyMeshObject) or (classof obj == Editable_poly) then (
return polyop.getNumFaces obj
)
if classof obj == Editable_Mesh do (
return getNumFaces obj
)
)
function faceID obj val = (
if (classof obj == PolyMeshObject) or (classof obj == Editable_poly) then (
return polyOp.getFaceMatID obj val
)
if classof obj == Editable_Mesh do (
return getFaceMatID obj val
)
)
function getIDs obj = (
arrID = #()
for i in 1 to (faceCount obj) do (
if (findItem arrID (faceID obj i)) == 0 then (
append arrID (faceID obj i)
)
)
return sort arrID
)
SubMats = getIds $
for i in 1 to SubMats.count do (
print $.material.materiallist[SubMats[i]].name
)This may not be the best or fastest way to go about it, but it does work.

-Eric

abyjoe
07-24-2007, 09:28 PM
thanks eric ur code does exactly what i was looking for...

CGTalk Moderation
07-24-2007, 09:28 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.