View Single Post
# 6 21-02-2012 , 06:24 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988

Would it be possible to merge it with the first script just as to uppercase the first letter of the material?

Of course. Give this a try:

Code:
string $nodeName[] = `ls -sl -tr -dag`;
string $matName, $sgName, $fileName;

for($i=0; $i<size($nodeName); $i++)
{
    $matName = `shadingNode -as phong -n ($nodeName[$i])`;
    $sgName = `sets -renderable true -noSurfaceShader true -empty -name ($nodeName[$i] + "SG")`;
    connectAttr -f ($matName + ".outColor") ($sgName + ".surfaceShader");
    select $nodeName[$i];
    sets -e -forceElement $sgName;

    int $nameSize = `size $matName`;
    string $firstCharacter = `substring $matName 1 1`;
    string $rest = `substring $matName 2 $nameSize`;

    string $newName = `toupper $firstCharacter` + $rest;

    rename $matName $newName;
}

clear $nodeName;
I've also changed the way $nodeName is populated. The way you had it, `ls -sl` would grab all selected nodes, not just geometry. I switched it to `ls -sl -tr -dag` to fix this. It means that it will grab all transform dag nodes for you.

Hope this works for you.

-John


Imagination is more important than knowledge.

Last edited by NextDesign; 21-02-2012 at 06:31 AM.