How to get name of parent?

Become a member of the CGSociety

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

Thread Tools Display Modes
  10 October 2012
How to get name of parent?

Lets say I do `ls -sl -tail 1` to get the last selected object and I now want to get the name of the group it's parented under - what command would I use for that? Neither "ls" nor "select" seem to have any flag for traversing up in the hierchy to select the parent.
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.

Last edited by DeadlyNightshade : 10 October 2012 at 07:30 AM.
  10 October 2012
pickWalk -d up
is what you are looking for.
Check the manual for the other flags
  10 October 2012
I think you can use the rootOf() command.

string $get[] = `ls -sl`;
string $root = rootOf($get[0]);

print $root

D'oh, or the pickWalk command. Someone beat me too it
  10 October 2012
don't ever use the pickWalk command to do something like this in a script. It relies on selections and is designed as an "action/operation" command so has bulky overheads.

If you want any hierarchy information (parents and children) use the listRelatives command.
  10 October 2012
Okay thanks guys.

listRelatives -parent; does the trick
rootOf is also a very handy command, but just as it's name suggest, it does not move up one step in the hierchy but blasts past everything and gets the root.
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
  10 October 2012
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
Society of Digital Artists

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

All times are GMT. The time now is 02:05 AM.

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