Copying/moving keyframes within the same layer channel?
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Copying/moving keyframes within the same layer channel?
I thought I'd write a tool to easily cut and insert "time" so that you could drag the tool and add/remove the corresponding amount of frames.
This means moving around keyframes. Is there a way to do this easily? The current scripting interface doesn't provide a way to read the interpolation type (at least I couldn't find it in the reference) so you can't duplicate a frame and be sure about the interpolation type by reading and re-adding a frame. Or is there a function to copy keyframes directly?
What I'm trying to do is to cut/add X amount of frames on every layer in the document so my plan is just move them backwards/forwards X frames. The only functionality that's built-in I've found to do this is "Rescale animation". I'd just write a handier tool for this. If there's already a tool for this, I'm happy to hear about it!
This means moving around keyframes. Is there a way to do this easily? The current scripting interface doesn't provide a way to read the interpolation type (at least I couldn't find it in the reference) so you can't duplicate a frame and be sure about the interpolation type by reading and re-adding a frame. Or is there a function to copy keyframes directly?
What I'm trying to do is to cut/add X amount of frames on every layer in the document so my plan is just move them backwards/forwards X frames. The only functionality that's built-in I've found to do this is "Rescale animation". I'd just write a handier tool for this. If there's already a tool for this, I'm happy to hear about it!
- synthsin75
- Posts: 9934
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Copying/moving keyframes within the same layer channel?
Get key interpolation:
Code: Select all
local Interp = 0
local ch = moho.layer.fTranslation
ch:GetKeyInterp(moho.frame, Interp)
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Copying/moving keyframes within the same layer channel?
Ooh thanks! The animestudioscripting.com didn't have this, but then again, it says there it's for version 10. (or if it did, then I missed this) Thanks again!
synthsin75 wrote:Get key interpolation:
Code: Select all
local Interp = 0 local ch = moho.layer.fTranslation ch:GetKeyInterp(moho.frame, Interp)
- synthsin75
- Posts: 9934
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Copying/moving keyframes within the same layer channel?
http://aslua.com/ is a better reference...aside from the scripting files included with AS (but even those occasionally end up out-of-date).
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Copying/moving keyframes within the same layer channel?
I'm trying to shift all the animation in the whole document and trying to find a good way to do this.
Some issues:
Looping through all layers:
-moho.document has CountLayers and Layer-function that gives me all the TOP-LEVEL layers. How do I access group layers and layers contained by bone layers? You can access layer's parent from a sub-layer, but how do I access the sub-layers from the parent-layer?
Moving keyframes:
-MohoLayer has "CopyFrame", but this seems to add keyframes even if there's no animation, so it's no use.
-Is there a way to access ALL the AnimChannels when I have the layer, so I could just loop through them? Then it would be easy to just check which ones have keyframes and duplicate them. AnimChannel even has a SwapKeys-function that would assumably make moving whole keyframes around easier.
Some issues:
Looping through all layers:
-moho.document has CountLayers and Layer-function that gives me all the TOP-LEVEL layers. How do I access group layers and layers contained by bone layers? You can access layer's parent from a sub-layer, but how do I access the sub-layers from the parent-layer?
Moving keyframes:
-MohoLayer has "CopyFrame", but this seems to add keyframes even if there's no animation, so it's no use.
-Is there a way to access ALL the AnimChannels when I have the layer, so I could just loop through them? Then it would be easy to just check which ones have keyframes and duplicate them. AnimChannel even has a SwapKeys-function that would assumably make moving whole keyframes around easier.
- hayasidist
- Posts: 3492
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Copying/moving keyframes within the same layer channel?
looping though all layers:
a group type layer has a count of child layers - see: http://aslua.com/index.php?show=method& ... ers&id=637 a recursive loop through that will pick out every layer in a doc.
finding and copying keyframes:
a layer has a count of the channels: see http://aslua.com/index.php?show=method& ... els&id=551 - beware: the last channel is "all" so the loop is for 1 = 0, moho.layer:CountChannels()-2 Also, document-wide channels such as camera stuff is likely to show in every layer.
a channel has a count of subchannels: see http://aslua.com/index.php?show=class&n ... yerChannel if that's more than 1 you'll need to scan sublayers
a (sub)channel will always have one key (at frame zero) so you'll want to pick out the ones with 2 or more keys.
a (sub)channel has a duration: see http://aslua.com/index.php?show=method& ... ion&id=418 ; and we've previously talked about a search for keys - if you're planning on adding space a "start at the back and move things further backwards" strategy is probably best
also take a look in the release directory ".../scripts/script writing" folder for (something like) lm_Listchannels.lua
hope that helps!
a group type layer has a count of child layers - see: http://aslua.com/index.php?show=method& ... ers&id=637 a recursive loop through that will pick out every layer in a doc.
finding and copying keyframes:
a layer has a count of the channels: see http://aslua.com/index.php?show=method& ... els&id=551 - beware: the last channel is "all" so the loop is for 1 = 0, moho.layer:CountChannels()-2 Also, document-wide channels such as camera stuff is likely to show in every layer.
a channel has a count of subchannels: see http://aslua.com/index.php?show=class&n ... yerChannel if that's more than 1 you'll need to scan sublayers
a (sub)channel will always have one key (at frame zero) so you'll want to pick out the ones with 2 or more keys.
a (sub)channel has a duration: see http://aslua.com/index.php?show=method& ... ion&id=418 ; and we've previously talked about a search for keys - if you're planning on adding space a "start at the back and move things further backwards" strategy is probably best
also take a look in the release directory ".../scripts/script writing" folder for (something like) lm_Listchannels.lua
hope that helps!
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Copying/moving keyframes within the same layer channel?
Wow, thanks for a through answer!!! I'll dig into this.
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Copying/moving keyframes within the same layer channel?
Just one quick clarification from the top of my head: what are subchannels? Is it like if there's channel "Perspective shadow", then subchannel would be "shadow scale", "shadow sheer" etc?
- synthsin75
- Posts: 9934
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Copying/moving keyframes within the same layer channel?
Yeah, any channel that has extra settings associated with its keyframes.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- hayasidist
- Posts: 3492
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Copying/moving keyframes within the same layer channel?
must say I've never bothered to look before you asked about layer perspective shadow! But .... if, e.g., the channel is point motion then the sub channels are one per point.
However, IMO it's mostly irrelevant exactly what the channels / sub channels are if all you're doing is copying. I'm not even sure you need to worry about channel type (e.g. scalar, vector, string ...).
However, IMO it's mostly irrelevant exactly what the channels / sub channels are if all you're doing is copying. I'm not even sure you need to worry about channel type (e.g. scalar, vector, string ...).
- synthsin75
- Posts: 9934
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Copying/moving keyframes within the same layer channel?
You can see all the channels and their subchannels by running Scripts>Script Writing>List Channels.
Point motion has no subchannels. Selected point motion is its own channel.
But yeah, shouldn't be much need to delve into subchannels just to move keyframes.
Point motion has no subchannels. Selected point motion is its own channel.
But yeah, shouldn't be much need to delve into subchannels just to move keyframes.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- synthsin75
- Posts: 9934
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Copying/moving keyframes within the same layer channel?
Uh, I haven't used them, but shouldn't these be all you need?
void CopyFrame(int32 fromFrame, int32 toFrame, bool recursive);
void DeleteFrame(int32 frame, bool recursive);
EDIT: Oh right, it keys all channels and doesn't preserve interpolation.
void CopyFrame(int32 fromFrame, int32 toFrame, bool recursive);
void DeleteFrame(int32 frame, bool recursive);
EDIT: Oh right, it keys all channels and doesn't preserve interpolation.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Copying/moving keyframes within the same layer channel?
Yea I was really excited when I found those but it's as shake they don't have some argument like "only copy keyframes" like some other functions. But with a little recursivity and a couple of haskey-checks, moving around keyframes will ever a breeze! I'll post here my finished subroutines when I get to it. Thanks for help!!!synthsin75 wrote:Uh, I haven't used them, but shouldn't these be all you need?
void CopyFrame(int32 fromFrame, int32 toFrame, bool recursive);
void DeleteFrame(int32 frame, bool recursive);
EDIT: Oh right, it keys all channels and doesn't preserve interpolation.
- hayasidist
- Posts: 3492
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Copying/moving keyframes within the same layer channel?
sorry to disagree Wes- but point motion does have subchannels (and selected point motion has subchannels if more than one point is selected)synthsin75 wrote:You can see all the channels and their subchannels by running Scripts>Script Writing>List Channels.
Point motion has no subchannels. Selected point motion is its own channel.
(screenshot here if you want to take a look: http://i128.photobucket.com/albums/p196 ... malgap.png)
and, whilst I haven't used it -- AnimChannel:SetKeyWhen(id, when) just might allow an existing id to be relocated?
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Copying/moving keyframes within the same layer channel?
hayasidist wrote:sorry to disagree Wes- but point motion does have subchannels (and selected point motion has subchannels if more than one point is selected)synthsin75 wrote:You can see all the channels and their subchannels by running Scripts>Script Writing>List Channels.
Point motion has no subchannels. Selected point motion is its own channel.
(screenshot here if you want to take a look: http://i128.photobucket.com/albums/p196 ... malgap.png)
and, whilst I haven't used it -- AnimChannel:SetKeyWhen(id, when) just might allow an existing id to be relocated?
Ooh, info worth gold! This would be so cool, to have the ability to move them instead of having to copy them.