PDA

View Full Version : Rename all non-DAG nodes that are not read-only?


Leffler
06-10-2009, 06:01 PM
Hi!

I want to add a prefix to all my nodes in the scene. For the dag-objects this one works fine


select -r "ALL";
SelectHierarchy ;

string $sel[] = `ls -sl -tr `;
string $newname;

for($x=0;$x<size($sel);$x++)
{
$newname = addPrefixToName( "prefixHere_", $sel[$x]);
rename ($sel[$x])($newname);
}


But what if i also want to rename for example all the condition-nodes? How do I get them? Since things like the defaultLayer is read-only, I have to manually select all the nodes and then run the script .... is there another way? I have tried stuff like listConnections and listRelatives but not quite getting there ...

Otto

tdHendrix
06-10-2009, 06:16 PM
I'm not sure if you want to rename only the condition nodes associated with the selected DAG objects or all the condition nodes in the scene, but if you want to do the later you can do this:


string $conditionNodes[] = `ls -typ "condition"`;

for ($current in $conditionNodes)
rename $current ("prefix_" + $current);

Leffler
06-10-2009, 07:03 PM
Well, not really but that would work. Rather ALL non-Dag nodes, such as clamp,condition,plusminusavg or whatever ...

Select all those, and rename all of them, except the ones that a read-only. Thatīs what I would want :)

tdHendrix
06-10-2009, 08:51 PM
See if this works:

listConnections defaultRenderUtilityList1;

Leffler
06-11-2009, 08:42 AM
It didnīt? Or what should I do with it?

ticket01
06-11-2009, 10:21 AM
You could use the MultiRename from my MultiTool. Tried it with some shaders and it works perfectly.

uiron
06-11-2009, 03:02 PM
import your scene into an empty scene, setting "resolve: [all nodes] with this string: [your prefix]".

problem solved.

Leffler
06-11-2009, 06:21 PM
Yeah I know there are several OTHER ways of solving this, just wanted this one right now :) Its for my autorig, to be able to rig several characters in the same scene

uiron
06-11-2009, 06:25 PM
use namespaces. or even better, write name-independed code. it's really possible. maya allows naming objects the same given they aren't under same parent.

although i don't see a problem of rigging a char per scene.

tdHendrix
06-11-2009, 08:01 PM
These commands give me all the utility node, texture nodes, and shading groups in my scene.

listConnections defaultRenderUtilityList1;
listConnections defaultTextureList1;
listConnections renderPartition;

Leffler
06-11-2009, 09:17 PM
Dont know if im tired or just retarded tonight but cant see how your doing it

This code



string $se2[] = `listConnections defaultRenderUtilityList1`;

for($y=0;$y<size($se2);$y++)
{
print ("SEL = " + $se2[$y] + "\n");
}

string $se3[] = `listConnections defaultTextureList1`;

for($t=0;$t<size($se3);$t++)
{
print ("SEL3 = " + $se3[$t] + "\n");
}

string $se4[] = `listConnections renderPartition`;

for($i=0;$i<size($se4);$i++)
{
print ("SEL4 = " + $se4[$i] + "\n");
}


Only gives me

SEL4 = initialShadingGroup
SEL4 = initialParticleSE

printed out, nothing more

tdHendrix
06-11-2009, 11:37 PM
I think you ran the code in a new scene maybe? Did you create utility and textures nodes? Otherwise I'm not sure what's going on.

Leffler
06-12-2009, 11:35 AM
Nope, hade lots of stuff in the scene. Weird.

tdHendrix
06-12-2009, 12:14 PM
Maybe it has to do with your version of Maya. I'm using Maya 2009. What version do you have? Anyways, all I did was select a utility node and looked at the Output section in the channelbox and noticed that for all my scenes they were connected to a node called defaultRenderUtilityList1, so you can see if yours has something similar.

djtomservo
06-12-2009, 06:23 PM
Hi!

I want to add a prefix to all my nodes in the scene. For the dag-objects this one works fine

Otto

if you want to rename EVERYTHING, why not just:


string $prefix= "blah_";
for($object in `ls`)
{
if( catchQuiet(rename($object,($prefix+$object))) )
{
warning("can't rename "+$object+"\n");
}
else
{
print("renamed "+$object+"\n");
}
}

CGTalk Moderation
06-12-2009, 06:23 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.