Page 1 of 3

Smarter "Copy Current frame..."

Posted: Wed Nov 15, 2017 12:09 pm
by Víctor Paredes
Hi. Do you know if there's a script that works in a similar way to the "Copy current frame..." option in the Animation menu?
I need to copy a frame of a very complex character into another frame.
The menu feature works if I check the "Copy entire animation" option, but it's far to be ideal, since it adds keyframes for all the channels of all the layers. And that is a lot of channels in a lot of layers...
What I'm looking for is a script that would only create keyframes for channels that already have animation and ignore the rest.

Do you know if any script with a similar behavior?

Thank you very much.

Re: Smarter "Copy Current frame..."

Posted: Wed Nov 15, 2017 7:28 pm
by Stan
So, as I see it, a menu/button script that will open a dialog with just "From frame: __ to frame __", and by clicking OK will copy all animated channels for the selected layer(s) only, including all sub-layers, right?

I could try to make it, just not sure if I have enough time this upcoming weekend...

Re: Smarter "Copy Current frame..."

Posted: Wed Nov 15, 2017 9:42 pm
by hayasidist
Since I've been working on channels recently I've got quite a few bits of code hanging around --- here's a snippet as a starter ... Only for Moho 12 or later

It gets the "all channels" channel for a layer and for every subchannel that is of non-zero duration sets a key at the target.

Code: Select all

	for j = 0, ctChannels-1 do 
		local chInfo = MOHO.MohoLayerChannel:new_local()
		moho.layer:GetChannelInfo(j, chInfo)
		local ch
		local subChans = chInfo.subChannelCount
		if chInfo.channelID == CHANNEL_LAYER_ALL then
				for k = 0, subChans - 1 do
					ch = moho.layer:Channel(j, k, moho.document) 
					local chDet
					if ch:Duration() > 0 then 
						if ch:ChannelType() == MOHO.CHANNEL_BOOL then
							chDet = moho:ChannelAsAnimBool(ch)
						elseif ch:ChannelType() == MOHO.CHANNEL_COLOR then
							chDet = moho:ChannelAsAnimColor(ch)
						elseif ch:ChannelType() == MOHO.CHANNEL_STRING then
							chDet = moho:ChannelAsAnimString(ch)
						elseif ch:ChannelType() == MOHO.CHANNEL_VAL then
							chDet = moho:ChannelAsAnimVal(ch)
						elseif ch:ChannelType() == MOHO.CHANNEL_VEC2 then
							chDet = moho:ChannelAsAnimVec2(ch)
						elseif ch:ChannelType() == MOHO.CHANNEL_VEC3 then
							chDet = moho:ChannelAsAnimVec3(ch)
						end
						local val = ch.value -- value at current frame (or use chDet:GetValue(inframe) )
						chDet:SetValue(outframe, val)
					end
				end
			end
		end
so you'll need to iterate over all layers (e.g. http://www.mohoscripting.com/index.php? ... ippet&id=1 ) and whatever UI you fancy..

Re: Smarter "Copy Current frame..."

Posted: Thu Nov 16, 2017 3:15 pm
by Víctor Paredes
Stan wrote:So, as I see it, a menu/button script that will open a dialog with just "From frame: __ to frame __", and by clicking OK will copy all animated channels for the selected layer(s) only, including all sub-layers, right?
I could try to make it, just not sure if I have enough time this upcoming weekend...
Yes, it's exactly that. Thank you very much for your message and I'm sorry i didn't answer you before.
Don't worry about writing the scripts (but huge thanks for the offer), we will see what can be done here.
It was I wasn't sure something similar was done in the past.
hayasidist wrote:Since I've been working on channels recently I've got quite a few bits of code hanging around --- here's a snippet as a starter ... Only for Moho 12 or later
This is great. Thank you very much for the help! We will explore the idea.

Re: Smarter "Copy Current frame..."

Posted: Thu Nov 16, 2017 3:59 pm
by Stan
Victor, if you just need the speed, there is a quick method MohoLayer:CopyFrame(fromFrame, toFrame, recursive). It copies every single channel, but does it very fast and easy.

Re: Smarter "Copy Current frame..."

Posted: Fri Nov 24, 2017 9:33 am
by A.Evseeva
Here is the tool that Stan mentioned above. It is our first collaboration.
http://revival.ru/test/ae_keytools.zip
To copy channel values go to source frame, press the COPY button, then go to target frame and press PASTE.
Keys will be created in animated channels only and in all the sub-layers if the "Child Layers" checkbox is checked.
It also can add new keyframes with ADD button using strange but useful logic (it is mainly for those animators who did not add keyframes before animating and found their previous animation destructed by new keyframes added later)

Re: Smarter "Copy Current frame..."

Posted: Thu Nov 30, 2017 1:46 pm
by Víctor Paredes
A.Evseeva wrote:Here is the tool that Stan mentioned above. It is our first collaboration.
http://revival.ru/test/ae_keytools.zip
Thank you very much A.Evseeva!
I'm sorry I couldn't reply before. The script seems to be working perfectly and it's exactly what we needed.
Thank you very much again for your generosity.

Re: Smarter "Copy Current frame..."

Posted: Thu Nov 30, 2017 5:50 pm
by Greenlaw
Good info in this thread!

I actually needed something like this last night. Will give some of these suggestions a try soon.

Re: Smarter "Copy Current frame..."

Posted: Mon Jan 29, 2018 4:38 pm
by Víctor Paredes
Hi, I just came to say I'm using this script a lot. Thanks again!

Re: Smarter "Copy Current frame..."

Posted: Fri Jun 22, 2018 8:46 am
by Víctor Paredes
Hi, I was wondering if there's a chance the copy/paste option of this script could work between different opened files.
Many times I need to use a pose of exactly the same character, but from a different file.
Do you know if that would be possible?

Thank you very much. And, again, this is script is fantastic. Currently I'm using it in every single scene I animate :)

Re: Smarter "Copy Current frame..."

Posted: Fri Jun 22, 2018 4:11 pm
by A.Evseeva
It already can do this for selected layer. I will try to add this feature for sublayers. Possible problem is assigning sublayers one to another if layer order was changed.

Re: Smarter "Copy Current frame..."

Posted: Fri Jun 22, 2018 7:53 pm
by A.Evseeva
Uploaded a new version which can copy-paste between open files including sublayers.
http://revival.ru/public_soft/lua/ae_keytools.zip

Re: Smarter "Copy Current frame..."

Posted: Sat Jun 23, 2018 9:36 am
by Lukas
A.Evseeva wrote:Uploaded a new version which can copy-paste between open files including sublayers.
http://revival.ru/public_soft/lua/ae_keytools.zip
Brilliant! Thanks for sharing.

Re: Smarter "Copy Current frame..."

Posted: Mon Jun 25, 2018 11:56 am
by Víctor Paredes
A.Evseeva wrote:Uploaded a new version which can copy-paste between open files including sublayers.
http://revival.ru/public_soft/lua/ae_keytools.zip
Thank you very much! I'm having some issues testing it in this project (but it's probably because these characters are very complex). I will try again when I get some time :)

Re: Smarter "Copy Current frame..."

Posted: Sat Sep 05, 2020 7:53 am
by A.Evseeva
Released a new version: http://revival.ru/public_soft/lua/moho_ ... l=keytools
new features:
- an option to select all the keys on all layers
- an option to exclude reference layers from this and other operations
- button to copy and paste key options (such as easy handles) from one key to another