CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-21-2005, 05:45 PM   #1
Nenox
Frequenter
 
Nenox's Avatar
Sune Kempf
IO Interactive
Copenhagen, Denmark
 
Join Date: Feb 2003
Posts: 178
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?

Code:
global proc string skReturnLong(string $createCommand){ select `eval $createCommand`; string $resultArray[] = `ls -sl -l`; string $returnName = $resultArray[0]; return $returnName; }


I can then go:

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


Any Thoughts?
__________________
--- rigging blog ---
www.sunekempf.com/blog
 
Old 10-21-2005, 06:09 PM   #2
Keilun
Expert
Keilun
Canada
 
Join Date: Aug 2005
Posts: 759
I don't think it gets any simpler than that, although you don't have to rely on the selection list for it:

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


So you could do something like this instead:

Code:
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-21-2005, 07:18 PM   #3
Nenox
Frequenter
 
Nenox's Avatar
Sune Kempf
IO Interactive
Copenhagen, Denmark
 
Join Date: Feb 2003
Posts: 178
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-21-2005, 07:24 PM   #4
Nenox
Frequenter
 
Nenox's Avatar
Sune Kempf
IO Interactive
Copenhagen, Denmark
 
Join Date: Feb 2003
Posts: 178
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-21-2005, 07:41 PM   #5
Keilun
Expert
Keilun
Canada
 
Join Date: Aug 2005
Posts: 759
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-21-2005, 07:54 PM   #6
Nenox
Frequenter
 
Nenox's Avatar
Sune Kempf
IO Interactive
Copenhagen, Denmark
 
Join Date: Feb 2003
Posts: 178
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-22-2005, 09:12 AM   #7
Keilun
Expert
Keilun
Canada
 
Join Date: Aug 2005
Posts: 759
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-22-2005, 09:12 AM   #8
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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
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 06:25 PM.


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