PDA

View Full Version : copy keys from one object to another..


Anubis
09-24-2005, 12:01 PM
So I have two controllers, both bidirectionally wired together. I want to copy the keyframes from one to another. Here is the issue.

1) When you wire something in max, it removes any keyframes it has.
2) When you copy all the keys of a controller to another, it unwires it.

So I would like to copy all the keys off the controller, wire it, and copy them back. The only way I can think to do this is to actually step through the keyArray and assignKey them one by one with an iterated function, but this level of maxscript is over my head.

I saw a script to just simply copy and paste keys and it was hundreds of lines of code. Why is this so damn difficult?

Thanks for the help,

RyanT
09-27-2005, 12:00 AM
Are the keys position/rotation/scale keys or are there any attributes as well?

RyanT
Pipeworks Software
Foundation 9

Anubis
09-27-2005, 12:10 AM
Just position/rotation actually.

RyanT
09-27-2005, 01:23 AM
In your utilities panel copy this into a new maxscript and execute it. It will pop up a window. First select the node you want to save animation from and save it to a file. Then use the second button to select the node you want to copy animaiton to. Then load the animation. This will put a key per frame or per every few frames based on an option. If you tell me what kind of controller it has I can set it up to save the keys specific to that controller. The reason it takes so much code to save off animation is there are many controllers in max and you have to compensate for all of them if you want to deal with any controller setup. The way I have this setup is very very general. I have one that is less general but its probably overkill for what you need.



rollout save_rollout"Save Animation"



(



local NodePicked = false



fn saveAnim =



(



if selection.count == 1 then



(



fname = getsavefilename caption:"Select file to export" types:"ANM File (*.anm)|*.anm|All Files (*.*)|*.*|"



if fname != undefined do



(



theFile = createfile fname



startT = animationrange.start



EndT = animationrange.end







samples = (animationrange.end as integer/ticksperframe)/save_rollout.Nframes.value



sampleRate = save_rollout.Nframes.value



frame = 0



for x = 1 to samples do



(



at time frame



(



for obj in selection do



(



format "%\n" frame to:theFile



format "%\n" obj.name to:theFile



format "%\n" obj.transform to:theFile



)



)



frame = frame + sampleRate



)



close theFile



)



)



else



(messagebox "Must select only one object!")



)







fn loadAnim =



(



fname = getopenfilename caption:"Select file to import" types:"ANM File (*.anm)|*.anm|All Files (*.*)|*.*|"



if fname != undefined do



(



f = openfile fname



while not eof f do



(



frame = (execute (readline f))



at time frame



(



animate on



(



if save_rollout.pickNode.object == undefined then



(

theNode = (getNodebyName (readline f))

print theNode

)



else



(

theNode = save_rollout.pickNode.object

(readline f)

)







theNode.transform = (execute (readline f))



)



)



)



)



)







button saveBtn "Save File" width:150 height:20



pickbutton pickNode "Pick New Node" width:150 height:20



button loadBtn "Load File" width:150 height:20



spinner Nframes "N Frames" width:100 range:[1,100,1] type:#integer align:#center











on saveBtn pressed do (saveAnim())







on pickNode picked node do (pickNode.text = node.name)







on loadBtn pressed do (loadAnim())



)



createDialog save_rollout width:180 height:110

RyanT
09-27-2005, 05:08 PM
For some reason when I pasted the code there was a problem. The above version has been edited and fixed.

-RyanT

CGTalk Moderation
09-27-2005, 05:08 PM
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.