help! list the shapenode which is assigned to lambert1

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 10 October 2011   #1
help! list the shapenode which is assigned to lambert1

i want create an script that can check my scenes;

if any object is assigned to lambert1,create a new lambert shader assign to them.



anyone can help? thanks a lot !!
 
Old 10 October 2011   #2
Hej...i don`t know if i got you right...therefore i wrote 2 different solutions.....

// Assign a new Lambert for each object with lambert 1


// list all objects in the Scene ( Poly, Nurbs, Subdiv)
string $allShapes[] = `ls -type "mesh" -type "nurbsSurface" -type "subdiv"`;

//loop through all objects
for($shape in $allShapes)
{

string $dest[] = `listConnections -destination true -source false -plugs false -type "shadingEngine" $shape`;

if($dest[0] == "initialShadingGroup")
{
string $newLambert = `shadingNode -asShader lambert`;
string $shadingGroup = `sets -renderable true -noSurfaceShader true -empty -name ($newLambert + "SG")`;
connectAttr -f ($newLambert + ".outColor") ($shadingGroup + ".surfaceShader");

sets -e -forceElement $shadingGroup $shape;
}


}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Assign one new Lambert for all objects with lambert1

// Solution with selecting objects
//could be quite heavy in a huge scene

hyperShade -objects lambert1;
string $allLambertObj[] = `ls -sl`;
string $newLambert = `shadingNode -asShader lambert`;
string $shadingGroup = `sets -renderable true -noSurfaceShader true -empty -name ($newLambert + "SG")`;
connectAttr -f ($newLambert + ".outColor") ($shadingGroup + ".surfaceShader");
sets -e -forceElement $shadingGroup $allLambertObj

////////////////////////////////////////////////////////////////////

// Solution without selecting objects
//pretty fast

string $initialSGConns[] = `listConnections "initialShadingGroup.dagSetMembers"`;
string $newLambert = `shadingNode -asShader lambert`;
string $shadingGroup = `sets -renderable true -noSurfaceShader true -empty -name ($newLambert + "SG")`;
connectAttr -f ($newLambert + ".outColor") ($shadingGroup + ".surfaceShader");
sets -e -forceElement $shadingGroup $initialSGConns;

////////////////////////////////////////////////////////////////////


I hope this works for you....cheers
 
Old 10 October 2011   #3
Originally Posted by Gidsche: Hej...i don`t know if i got you right...therefore i wrote 2 different solutions.....

// Assign a new Lambert for each object with lambert 1


// list all objects in the Scene ( Poly, Nurbs, Subdiv)
string $allShapes[] = `ls -type "mesh" -type "nurbsSurface" -type "subdiv"`;

//loop through all objects
for($shape in $allShapes)
{

string $dest[] = `listConnections -destination true -source false -plugs false -type "shadingEngine" $shape`;

if($dest[0] == "initialShadingGroup")
{
string $newLambert = `shadingNode -asShader lambert`;
string $shadingGroup = `sets -renderable true -noSurfaceShader true -empty -name ($newLambert + "SG")`;
connectAttr -f ($newLambert + ".outColor") ($shadingGroup + ".surfaceShader");

sets -e -forceElement $shadingGroup $shape;
}


}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Assign one new Lambert for all objects with lambert1

// Solution with selecting objects
//could be quite heavy in a huge scene

hyperShade -objects lambert1;
string $allLambertObj[] = `ls -sl`;
string $newLambert = `shadingNode -asShader lambert`;
string $shadingGroup = `sets -renderable true -noSurfaceShader true -empty -name ($newLambert + "SG")`;
connectAttr -f ($newLambert + ".outColor") ($shadingGroup + ".surfaceShader");
sets -e -forceElement $shadingGroup $allLambertObj

////////////////////////////////////////////////////////////////////

// Solution without selecting objects
//pretty fast

string $initialSGConns[] = `listConnections "initialShadingGroup.dagSetMembers"`;
string $newLambert = `shadingNode -asShader lambert`;
string $shadingGroup = `sets -renderable true -noSurfaceShader true -empty -name ($newLambert + "SG")`;
connectAttr -f ($newLambert + ".outColor") ($shadingGroup + ".surfaceShader");
sets -e -forceElement $shadingGroup $initialSGConns;

////////////////////////////////////////////////////////////////////


I hope this works for you....cheers






thanks a million!!


it works!!!
 
Old 10 October 2011   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:44 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.