PDA

View Full Version : Returning the full path when creating nodes?


Nenox
10-21-2005, 06:45 PM
Hi.

I often want to get the full path when i create nodes. But Maya does not return these. I'v made a little proc that helps me do this, but i wonder if there is not a simpler way?

global proc string skReturnLong(string $createCommand){

select `eval $createCommand`;
string $resultArray[] = `ls -sl -l`;
string $returnName = $resultArray[0];

return $returnName;

}

I can then go:

string $ankleCtrl = skReturnLong("group -em -w -n hans");

Any Thoughts?

Keilun
10-21-2005, 07:09 PM
I don't think it gets any simpler than that, although you don't have to rely on the selection list for it:

ls -l nurbsSphere1;
// Result: |nurbsSphere1 //

So you could do something like this instead:

global proc string skReturnLong(string $createCommand) {

string $cmdArray[] = `eval $createCommand`;
string $resultArray[] = `ls -l $cmdArray[0]`;
return $resultArray[0];
}

Small point, but if you ever need to retrieve the long name without modifying the selection list, then this becomes an issue.

Nenox
10-21-2005, 08:18 PM
Cool!

For my purposes though, that code has the slight advantage of eventualy returning the long name of another object in the scene, that has the same name as the newly created one. This is exately why i went with the selected command..

BUT!! I just found that my code is quite messed up. If there is another node in the scene with the name of the node you are trying to create, the select command fails:

// Error: More than one object matches name: ankleCtrl_L //

So, i need something else. hm...

Thanks for the input!

Nenox
10-21-2005, 08:24 PM
Correction. I get the errormassage, but it is allways the new node that is selected. So, apparentely it works. Unless the errer will get my main script into trouble.

Keilun
10-21-2005, 08:41 PM
Hm. I'm pretty sure the string result returned by the command will always return the shortest unique name so it shouldn't ever pick up another object with the same name - the internal commands do their own name clash resolution. But as long as you have a method that works for you though, its all good.

Nenox
10-21-2005, 08:54 PM
Cheers!

Well, I tried you code again and must confess that you are absolutely right. Since creating an empty group (see first post) does not return an array, I had changed your code a bit. Apparently a little too much! :-)

Thanks a bunch

Keilun
10-22-2005, 10:12 AM
Glad I could help. One other thing I guess for roundness would be to have two of those functions one for commands that return string arrays and ones that return a single string. It's doubtful we'll find one procedure that will handle them all. Good luck!

CGTalk Moderation
10-22-2005, 10:12 AM
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.