# Keyframed animation convert to driven key anim...?

**URL:** https://forum.highend3d.com/t/keyframed-animation-convert-to-driven-key-anim/3979
**Category:** Maya
**Tags:** mel
**Created:** [January 6, 2005, 8:30pm UTC](https://forum.highend3d.com/t/keyframed-animation-convert-to-driven-key-anim/3979 "2005-01-06T20:30:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![masternull](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@masternull](https://forum.highend3d.com/u/masternull)
#### Post date: [January 6, 2005, 8:30pm UTC](https://forum.highend3d.com/t/keyframed-animation-convert-to-driven-key-anim/3979/1 "2005-01-06T20:30:50Z")

</div>

is there a script to take existing keyframe animation, and covert it to a driven-key animation?

rather than manually picking and driven-keying all joints and creating an animation that way, it would use the keyframes you have created and convert the whole animation to be driven by an attribute beteen 0 and 1.

ie: i have a simple looped walking bug, keyframed it out to loop between frames 0 and 30, and now want the loop to be driven by a single locator keyed betweeen 0 and 1 on pX. i have multiple walk cycles already made and don't want to waste time by redoing the animation to make it a driven key based animation... the main reason i need this rather than using trax is that i want the bug to walk along a path at a correct rate...

thanks for any help y'all

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [January 6, 2005, 10:57pm UTC](https://forum.highend3d.com/t/keyframed-animation-convert-to-driven-key-anim/3979/2 "2005-01-06T22:57:36Z")

</div>

No biggie just connect a custom time to the anim curves input (infact a sdk is just a anim curve), you can do a mel loop and connect all anim curves to this cutom time or attribute

Brief demo (paste in new empty scene)

{//protected block  
 //lets create some anim  
 sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;  
 setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 0 {"nurbsSphere1"};  
 currentTime 40 ;  
 move -r -1 2 1;   
 rotate -r -os -10 0 10;  
 setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 0 {"nurbsSphere1"};  
 currentTime 80 ;  
 move -r 1 -2 3 ;  
 rotate -r -os -10 0 0;  
 setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 0 {"nurbsSphere1"};  
 //lets get the connected anim curves  
 $curves=`listConnections -type animCurve nurbsSphere1`;  
 //add driving attribute  
 addAttr -ln customTime -at double -min 0 -max 1 |nurbsSphere1;  
 setAttr -e -keyable true |nurbsSphere1.customTime;  
 //normalize time (one could also scale the curves!)  
 createNode multiplyDivide;  
 connectAttr -f nurbsSphere1.customTime multiplyDivide1.input1X;  
 setAttr "multiplyDivide1.input2X" 80;  
 //connect normalized time to curves  
 for ($curve in $curves)  
 connectAttr -f multiplyDivide1.outputX ($curve +".input");  
 //select the sphere   
 select -r nurbsSphere1 ;  
}  
And manipulate the custom time!

---

<div class="post-metadata">

### Author: ![masternull](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@masternull](https://forum.highend3d.com/u/masternull)
#### Post date: [January 7, 2005, 1:04am UTC](https://forum.highend3d.com/t/keyframed-animation-convert-to-driven-key-anim/3979/3 "2005-01-07T01:04:27Z")

</div>

interesting.... i am not a very good scripter, but i see whats going on there, how would i use this on lets say a bunch of joints? and if the custom time is always changing (connected to U value of a curve)...

---

<div class="post-metadata">

### Author: ![masternull](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@masternull](https://forum.highend3d.com/u/masternull)
#### Post date: [January 7, 2005, 3:19am UTC](https://forum.highend3d.com/t/keyframed-animation-convert-to-driven-key-anim/3979/4 "2005-01-07T03:19:47Z")

</div>

i wrote something that uses get attribute, a duplicate rig looks at my keyframed one, matches it and then sets the driven keys and so on for a frame range... looks like this:

//Keys to Drive  
//  
// KeysToDrive(firstframe,lastframe);  
//  
//

global proc KeysToDrive(int $start, int $end){

```
int $i;
for($i=$start; $i<$end; $i++){

	currentTime -e $i;
```

// crab\_base

float $tx = `getAttr "X\_crab\_base.tx"`;  
setAttr "crab\_base.tx" $tx;  
float $ty = `getAttr "X\_crab\_base.ty"`;  
etc....

select -r crab ;

setDrivenKeyframe -cd crab.walkCycle crab\_clawend\_Lt.translateX;  
setDrivenKeyframe -cd crab.walkCycle crab\_clawend\_Lt.translateY;  
setDrivenKeyframe -cd crab.walkCycle crab\_clawend\_Lt.translateZ;  
setDrivenKeyframe -cd crab.walkCycle crab\_clawend\_Lt.rotateX;  
etc...

it works!

thanks for your advice ...
