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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 10 October 2005   #1
Returning the full path when creating nodes?

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?
__________________
--- rigging blog ---
www.sunekempf.com/blog
 
Old 10 October 2005   #2
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.
 
Old 10 October 2005   #3
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!
__________________
--- rigging blog ---
www.sunekempf.com/blog
 
Old 10 October 2005   #4
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 ---
www.sunekempf.com/blog
 
Old 10 October 2005   #5
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.
 
Old 10 October 2005   #6
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
__________________
--- rigging blog ---
www.sunekempf.com/blog
 
Old 10 October 2005   #7
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!
 
Old 10 October 2005   #8
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.
 
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 01:13 AM.


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