Maya Mel - query set driven key

Hi,

I’m trying to query a set driven key keyframe value.

In the attached example, I already know the driver channel, driver value, and driven channel. ( in this case pCube1.tx = 0 & the driven channel is joint1.ty ).

Does anyone know how can I query the driven value of joint1.ty when pCube1.tx = 0 via .mel command?

Much Thanks!

//im thinking this is what your after
setAttr pCube1.tx 0; //go to the value you want
getAttr joint1.ty; //get the driven value

//or a little cleaner cause we restore things
float $cur = getAttr pCube1.tx; //get the current channel value for pCube1’s translate X
float $value; //this will hold what we want the sdk value
setAttr pCube1.tx 0; //go to the value you want
$value = getAttr joint1.ty; //get the driven value
setAttr pCube1.tx $cur; //restore back to initial

There might be some bugs in the code (no checking for locked attributes, etc), but hope this helps.

Regards,
Nate

Thanks Nate.

>>Does anyone know how can I query the driven value of joint1.ty when pCube1.tx = 0 via .mel command?

I apologize. I should have asked this better.

What I really want to query is the set driven keyframe value. setDrivenKey command seems to only give you the driver and driven object + channels. Is there something like this that will give you the set driven keyframes values?

// To query the available drivers of pCone1.tx:
setDrivenKeyframe -q -dr pCone1.tx;

You can just query the anim curve using the keyframe command. The floats provide the driven input.

keyframe -at “ty” -float 0 -q -eval “joint1”;

[QUOTE=tonthebone;14570]Is there something like this that will give you the set driven keyframes values?

// To query the available drivers of pCone1.tx:
setDrivenKeyframe -q -dr pCone1.tx;[/QUOTE]

I think for an animation curve that is animCurveUL (when I made a sdk through the maya ui, this was the type of curve i got) you want to get the animation curve for the set driven key and use the keyTimeValue[#].keyTime attribute of the animation curve. It gives the keyframe value. You can find that curve using a few ways I think opening the hypergraph:hierarchy window, selecting your driven node, and then showing input connections is a possible way.

//for your example if joint1_translateY is the appropriate animation curve of type animCurveUL
//to get how many set driven keyframes
int $n = size( getAttr joint1_translateY.keyTimeValue[0] );
//then to get the first keyframe
getAttr joint1_translateY.keyTimeValue[0].keyTime;
//to get the second keyframe
getAttr joint1_translateY.keyTimeValue[1].keyTime;
//to get the last keyframe
getAttr joint1_translateY.keyTimeValue[($n-1)].keyTime;

There might be bugs, and I may be wrong and the keyframe command works with these types of curves too.

Hope this helps.
Regards,
Nate

Thanks for the help, guys. I think I’m going in the right direction, now.

per Paul’s suggestion: I discovered this.

//–find the driver object and channel from the driven object
string $driverObject[] = setDrivenKeyframe -q -cd joint1;

//—find the driven channels
string $drivenChannels[] = setDrivenKeyframe -q -dn joint1;

//—find driver value from driverObject.channel
float $driverVal[] = keyframe -q -fc $drivenChannels[1];

//—find the driven value from drivenObject.channel,
float $drivenVal[] = keyframe -q -vc $drivenChannels[1];

This works great except when there is a blendWeighted node in the mix. With blendWeighted node, you can’t seem to query the keyframe this way.

Per Nates response: This worked for me, but was complicated by the existence of blendWeighted nodes. To get around them, I’m using this:

string $connected[] = listConnections driven.channel ;
listConnections -type animCurveUU $connected[0] ;

This is giving me the connected anim curves I need.

Thanks again for the responses!

Tony

I know this thread is old, but for anyone else on google who finds this post: remember to use the “scn” flag to skip conversion nodes when finding the driven channels using listConnections. Otherwise it will still not work for rotation values, as you will just run into the unitconversions