getAttr returning unpredictable data types - Very Puzzled

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
  02 February 2013
getAttr returning unpredictable data types - Very Puzzled

Hi All,

New member here. Been away from Maya for several years, but getting back into it. I used to write MEL code for living, and a lot of it is coming back to me, but now I've run into something that I can't figure out.

I'm writing a script that loops through all the joints in the hand of a biped rig I've created, and does a getAttr on the rotate and scale values of each joint so that they may be stored elsewhere. On certain joints, the getAttr command returns not one value but an array of *three* values. But only on certain joints, not on all. For example:

getAttr "r_fing_idx_meta.rx";
// Result: 0 //
getAttr "r_fing_idx_base.rx";
// Result: 0 0 0 // <---- ????
getAttr "r_fing_mdl_meta.rx";
// Result: 0 //
getAttr "r_fing_mdl_mid.rx";
// Result: 0 0 0 // <---- ????

And, it's not just limited to the fingers:

getAttr "r_loarm.rx";
// Result: -0.00749007 //
getAttr "r_uparm.rx";
// Result: 0.00541012 //
getAttr "r_hand.rx";
// Result: 0.000577426 0 0 // <---- ???

This has got me dead in the water, as I can't return the results of the getAttr into anything without knowing whether the returned data will be float or float[].

I can't discern any difference between the joints. I guess my next debugging step is to re-create the joints that are returning float arrays for a single channel and see what happens.

If anyone has an explanation for why this is happening, or ideas on how to work around it in MEL, please share!

Thanks,

James
 
  02 February 2013
Follow-up: I unwrapped one layer in this mystery enough that I was able to find a solution and get my script working.

There were stand-in geometry objects (meshes) that shared names with the joints I was trying to query. Where there was a joint without a same-named mesh, the getAttr command behaved as it should, returning a single value for rotate channel queries.

There were two work-arounds: 1) add code to handle the joints via their full pathnames, or 2) give the objects unique names to distinguish them from the joints. I chose the latter.

James
 
  02 February 2013
You could always use xform I guess to return a triple float.
__________________
Vimeo
 
  02 February 2013
This sounds really strange...
I have no direct solution for that, but instead of writing:
float $pos[3] = `getAttr  node.rx`;


you could also write:
$pos = `getAttr node.rx`;


withoug prior declaration of the variable.
Then you could check if its an array or a simple float.
You could also use "catchQuiet" command.
 
  02 February 2013
Quote: There were two work-arounds: 1) add code to handle the joints via their full pathnames, or 2) give the objects unique names to distinguish them from the joints.


Ah, dang!
I remember, I had similar problems long ago:
Yes, even though the full DAG path is different, Maya can often not distinguish between nodes which share the same short name and then outputs results for all objects it can detect.
That was the time I started to give every DAG object a true unnique name.



edit: the post order is wrong ( again )

Last edited by sciLoop : 02 February 2013 at 10:25 AM.
 
  02 February 2013
Thanks for the note - some interesting ideas here. In the end I had to manage the names of my nodes a bit better.

James
 
  02 February 2013
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:01 AM.


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