PDA

View Full Version : double name / naming - name clash


martinputtkammer
05-13-2008, 07:06 AM
hi,

is it possible in mel or python to query the full, absolute path of a dag node without
using the transform node's name?

i got a script which changes the names of a selection list in a loop and i cannot update
the selection after every loop, since it would render the script unusable.

any pointers are appreciated,
martin

damat
05-13-2008, 09:54 AM
Haven't really figured out, but:

1. ls -sl -l;
// Result:|group27|polySurface1//

2. string $objects[] = `ls -sl`;
string $parent[] = `listRelatives -parent -f $objects[0]`;
// Result:|group27//

3. if results contain excessive symbols/words, use tokenize function to split and cut them

martinputtkammer
05-13-2008, 10:09 AM
hi damat,

thanks for helping.

i didn't know it is possible to query the parents directly.
by using that i should be able to update the paths by constantly refeeding the parents
on renaming, but it'll make for cluttered code.

but it works :). thank you.

martin

martinputtkammer
05-24-2008, 02:58 PM
just an addendum:

if you parent 20 objects with the SAME NAME beneath each other, so that every object has exactly one child:

if you then get your selection of all those objects:
my_selection = cmds.ls(sl=1)

every object name will be similar to:
name|name|name|name|name...

if your script then changes one name in the row, then all object paths below that objects
will be broken, because the paths changed.

sometimes it is not possible to update the selection again during script execution:

So:

How do you get a reliable way to get your hierarchy selection updated properly?:
Simple, but effective:

use the "message" info node to link the dag nodes to each other, mimicking the hierarchy they are situated in, then, by tracing the message node connections you can work your way through the hierarchy, even if the names of the objects changed.

other possible approaches:

attach a custom attribute for each object to identify it.

use listRelatives on all the objects, like damat described. can be a pain and slow for
huge hierarchies

martin

CGTalk Moderation
05-24-2008, 02:58 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.