PDA

View Full Version : exigency question about "ls"


FangHongyi
04-23-2007, 02:12 PM
Hi everybody:
I have a question about using "ls" to list object's name in a complex scene.when i write " string $aaa[] = `ls -sl -tr`;" to get the selected object name. some of them returns "group|objectName",and some of them not. it makes me hard to operate using their names.
so how can I just get it's name without "group |" before its name. Thanks!!!:shrug:

JamesPiechota
04-24-2007, 12:38 AM
If Maya's returning a path like group|objectName it probably means you have 2 objects called 'objectName' in your scene. Non-dag nodes are always guaranteed to be uniquely named, but you can have two DAG nodes with the same name if they have different dag paths.

When referring to one of the duplicately named nodes you have to give enough of its DAG path so that Maya knows which one you're referring to. The `ls` command will always return a name that can be used to correctly identify a node, i.e. if a node is duplicately named `ls` will return enough of its DAG path to disambiguate.

If you don't care about manipulating the node using another MEL command and only want the string representing its name, you can use the 'tokenize' MEL command to chop off all but the last section of the DAG path.

FangHongyi
04-24-2007, 02:06 PM
If Maya's returning a path like group|objectName it probably means you have 2 objects called 'objectName' in your scene. Non-dag nodes are always guaranteed to be uniquely named, but you can have two DAG nodes with the same name if they have different dag paths.
.
Hi JamesPiechota:
Thank you for your instruction. you're right.My scene do have repetitive name.Some idiot of my workmates use object name to name the Shapenode name. Thank you for answer me. :thumbsup:

FangHongyi
04-24-2007, 02:12 PM
**Deleted double post**

CGTalk Moderation
04-24-2007, 02:12 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.