Pages

Wednesday, August 5, 2009

Material name in MAXScript

Well, again something about MAXScript. A ScriptSpot user stick on object material name. He just wanted to print in Max Listener the list of selected objects with their material name. You know, objects always has names but their material is optional, so shortly, when we work with object materials is not only important, even binding to check if they has material applyed/assigned.

Also in the forum topic, the user ask for help on how to sort the list by 2 ways - ObjectName + ObjectMaterial and ObjectMaterial + ObjectName. For this task can be tested many ways, dependent on that method we prefer to collect and print the list. If someone interesting about current script, there it is:
 ---------------------------------------
sel = selection as array
arrObjMtl = #()
arrMtlObj = #()
for i in sel do
(
if i.material != undefined then (
append arrObjMtl (i.name + " :: " + i.material.name)
append arrMtlObj (i.material.name + " :: " + i.name)
)
else (
append arrObjMtl (i.name + " :: " + "--")
append arrMtlObj ("--" + " :: " + i.name)
)
)
sort arrObjMtl ; sort arrMtlObj
for i in arrObjMtl do print i
for i in arrMtlObj do print i
---------------------------------------

No comments:

Post a Comment

Thanks for your comment