int $i = 0;
string $allObjects[];
string $obj;
$allObjects = `ls -sl`;
string $shapes[] = `listRelatives $allObjects`;
string $myMaterial[] = `listConnections -type "shadingEngine" $shapes`;
for ( $obj in $allObjects ) {
print ($myMaterial[$i] + "\n");
addAttr -dt "string" -ln "material";
setAttr ($obj+".material") -type "string" $myMaterial[$i];
print ($obj+".material" + "\n");
$i++;
};
reference:(Thx for sharing)
https://forums.cgsociety.org/t/how-to-list-materials-for-selected-objects/1394337
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/Commands/setAttr.html
http://me.autodesk.jp/wam/maya/docs/Maya2009/Commands/ls.html
http://www.not-enough.org/abe/manual/maya/mel-tips.html#getAttrAs
https://forums.cgsociety.org/t/mel-query-custom-attributes/1402479
No comments:
Post a Comment