CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-21-2013, 09:32 AM   #1
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
Exclamation 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
 
Old 02-22-2013, 12:58 AM   #2
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
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
 
Old 02-22-2013, 08:40 AM   #3
Aikiman
Pixel Collisions
 
Aikiman's Avatar
portfolio
Jeremy Raven
Wellington, New Zealand
 
Join Date: Jun 2005
Posts: 3,582
You could always use xform I guess to return a triple float.
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 02-22-2013, 09:00 AM   #4
sciLoop
Expert
 
sciLoop's Avatar
portfolio
Burkhard Rammner
bioinformatition
med.uni.goettingen/sciloop
Hamburg, Germany
 
Join Date: Sep 2008
Posts: 511
This sounds really strange...
I have no direct solution for that, but instead of writing:
Code:
float $pos[3] = `getAttr node.rx`;


you could also write:
Code:
$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.
 
Old 02-23-2013, 10:21 AM   #5
sciLoop
Expert
 
sciLoop's Avatar
portfolio
Burkhard Rammner
bioinformatition
med.uni.goettingen/sciloop
Hamburg, Germany
 
Join Date: Sep 2008
Posts: 511
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-23-2013 at 10:25 AM.
 
Old 02-24-2013, 12:15 PM   #6
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
Thanks for the note - some interesting ideas here. In the end I had to manage the names of my nodes a bit better.

James
 
Old 02-24-2013, 12:15 PM   #7
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:02 PM.


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