Returning the full path when creating nodes?

Become a member of the CGSociety

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

Thread Tools Search this Thread Display Modes
  10 October 2005
Returning the full path when creating nodes?


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?
--- rigging blog ---
  10 October 2005
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.
  10 October 2005

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!
--- rigging blog ---
  10 October 2005
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.
--- rigging blog ---
  10 October 2005
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.
  10 October 2005

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
--- rigging blog ---
  10 October 2005
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!
  10 October 2005
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 09:23 PM.

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