Notifications
Clear all

[Closed] Copy and pasting keyframes

Hey all, i’m very new to maxscript i need a help on this;
in scene i have an animated object that have 4 keyframes, is that possible to copy paste same frames along a frame number that i choice? like i want that animation between 0-75 with using base 4 frames.
like that:
o Oo
1 34

what i need:
o Ooo Ooo Ooo Ooo Ooo Ooo Oo
123456789…
here is the scene file

note: i know how to copy paste in curve editor but need to make it with maxscript.

2 Replies

I knocked up a quick script that copies key frames based on time. You can select the range you want to copy and then paste it with an offset. Not great code but does the job.
It could do with clearing the keyframes from the End-range before copying and maybe adding and adjusting the keys for rigid or smooth animation but I’ll leave that one for you.

 
(
range_start = 0 --first time frame to copy
range_end = 4 -- last time frame to copy
paste_start = 25 --first frame time to copy to
paste_repeat = 2 -- no. of repetitions
 
object_keys = $.pos.controller.keys.count
range_keys = 0
 
 --get keys within time range
 for n = 1 to object_keys do
  (
  if ($.pos.controller.keys[n].time.frame as integer) <= range_end then range_keys += 1  
  )
 for n = 1 to range_keys do
  (
  for t = 1 to paste_repeat do
   (
   with animate on at time ((paste_start * t) + ($.pos.controller.keys[n].time.frame 
as integer))
	(
	$.pos.x = at time ($.pos.controller.keys[n].time) $.position.x
	$.pos.y = at time ($.pos.controller.keys[n].time) $.position.y
	$.pos.z = at time ($.pos.controller.keys[n].time) $.position.z
	$.rotation = at time ($.pos.controller.keys[n].time) $.rotation
	$.scale = at time ($.pos.controller.keys[n].time) $.scale
	)
   )--paste_repeat 
  )--range_keys

No expert, but you might look at setBeforeORT, setAfterORT, enableORTs etc, if your case is always in the form of exact repetition, and using Out-Of-Range Types is appropriate.