Copy/Paste Animation with Relative Values

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2011   #1
Copy/Paste Animation with Relative Values

I've been trying to find an answer to this for quite some time but no luck.

Let's say I have a hundred cubes. They are in different random positions. All of these cubes move 100 units -z in 5 frames, then 50 units +x in 10 frames and goes like this. They all have identical animation but all of them start animating at different frames. At the moment I'm manually keying every single object. It's ok for couple of objects but when you're keying hundreds of them, it becomes pain.

Is there any way to make this task easier? I know I can duplicate the first object after animating it and offset its keys, that sure will be easier but since I have all my objects copied and positioned in place, so this is not an option. Also copy/paste animation will not work because it copies absolute values. I'd like to copy/paste it with relative values.

I have a script idea. This script will have 2 buttons. First button will copy animation of the selected object (including keys in visibility channel if they exist). Second button will paste that copied animation to the selected object starting at current frame. So I will select my animated object, press copy button, then select 2nd object, move time slider to desired position, press paste button, then select 3rd object and paste, etc.

I have no scripting experience so I dont know if it does make sense and easy to do. Any help is much appreciated, thanks in advance.
 
Old 06 June 2011   #2
try this.

Let me know if it works out for you:

global rl_copyPasteAnim
try(destroyDialog rl_copyPasteAnim) catch()
rollout rl_copyPasteAnim "Copy and Paste Animation"
(
	global theController
	button btn_copyAnim "COPY ANIMATION"
	button btn_pasteAnim "PASTE ANIMATION"
	
	on btn_copyAnim pressed do
	(
		if selection[1] != undefined and selection[1].controller != undefined then (theController = selection[1].controller)
		else (messagebox "Please select an animated object")
	)
	
	on btn_pasteAnim pressed do
	(
		if theController != undefined then 
		(
			theTime = sliderTime - animationRange.start
			with animate off
			(
				for s in selection do
				(
					
					theTM = s.transform
					s.controller = copy theController
					inserttime s.controller animationrange.start theTime
					s.transform = theTM
				)
				slidertime = slidertime+1
				slidertime = slidertime-1
			)
		)
		else (messagebox "Please copy an animation")
	)
	
	on rl_copyPasteAnim close do
	(
		theController = undefined
	)
)
createDialog rl_copyPasteAnim
 
Old 06 June 2011   #3
It works perfectly, thank you so much!!! One little thing, how can I copy also visibility keys? This script doesnt seem to paste visibility only transform works.

Thanks again.
 
Old 06 June 2011   #4
Here ya go. . .

global rl_copyPasteAnim
try(destroyDialog rl_copyPasteAnim) catch()
rollout rl_copyPasteAnim "Copy and Paste Animation"
(
	global theController, theVisController
	button btn_copyAnim "COPY ANIMATION"
	button btn_pasteAnim "PASTE ANIMATION"
	
	on btn_copyAnim pressed do
	(
		theController = theVisController = undefined
		if selection[1] != undefined and selection[1].controller != undefined then 
		(
			theController = selection[1].controller
			if selection[1][1].controller != undefined then (theVisController = selection[1].visibility.controller)
		)
		else (messagebox "Please select an animated object")
	)
	
	on btn_pasteAnim pressed do
	(
		if theController != undefined then 
		(
			theTime = sliderTime - animationRange.start
			with animate off
			(
				for s in selection do
				(
					
					theTM = s.transform
					s.controller = copy theController
					inserttime s.controller animationrange.start theTime
					if theVisController != undefined then
					(
						if s[1].controller == undefined then s.visibility = bezier_float()
						s.visibility.controller = (copy theVisController)
						inserttime s.visibility.controller animationrange.start theTime
					)
					s.transform = theTM
					
				)
				slidertime = slidertime+1
				slidertime = slidertime-1
			)
		)
		else (messagebox "Please copy an animation")
	)
	
	on rl_copyPasteAnim close do
	(
		theController = theVisController = undefined
	)
)
createDialog rl_copyPasteAnim
 
Old 06 June 2011   #5
jonlauf it's working. Much appreciated, god bless you and your family.
 
Old 06 June 2011   #6
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



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 11:14 AM.


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