Clean keyframes script?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Clean keyframes script?

Post by Lukas »

That was fast! Great work, so far it all works perfectly. Thanks a lot! :mrgreen:
synthsin75 wrote:Lukas, it won't work exactly like you colored the keys in your example file. It always leaves the last keyframe in a channel, but if I got enough feedback that that was undesired, I could change that.
I can imagine that's actually the best way to do it, since the last keyframes might be the first pose of a new pose-to-pose segment. So leaving them is the best way to handle it indeed!
synthsin75 wrote:And if you use that file to test separate dimensions, the z-axis is unchanged, so it will only leave the last key on that channel.
Perfect
synthsin75 wrote:Still doesn't handle camera channels.
No sweat :) Camera keys are usually quite easy to keep clean manually, compared animated objects.

Any chance of this tool also working for points someday? (I can imagine that's an entirely different beast and much harder to do)
EDIT: I just checked and realized it also works for points already, AWESOME!
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Clean keyframes script?

Post by synthsin75 »

Glad to hear it's doing everything you need, Lukas.
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Clean keyframes script?

Post by Lukas »

Hmmm, actually I've been coming across this one situation where it's actually wishful to delete the last keyframe also a few times already.

When the last keyframe is the only keyframe in a channel and it has the same value as frame 0, it would be better if it would be deleted.

For example:

I've been animating a few shots, I press Ctrl+F to freeze the poses all the time. And adjust the poses along the way. Very often I only use translate and rotate bone and don't use scale bone at all in a shot.

So when I'm done with the rough animation, everything pose to pose, I'd like to press 'clean keys' and continue on the details with a nice clean timeline. The problem is, even though I haven't touched scale bone on any of the bones. On the last pose, the scale keys will always remain there. (And so will the channels when they are set to 'auto' in the channel visibility window). You'd expect the scale channels to dissapear if you haven't animated them at all.

So in those cases, when the last key is the only key and it matches frame 0, I think it would be better of cleaned/deleted. :) I hope that makes sense.
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Clean keyframes script?

Post by Lukas »

Okay, after using your script a bit more, I'm certain it would definitely be more useful if the last key would also be deleted if it is 'obsolete'. At all times :)
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Clean keyframes script?

Post by synthsin75 »

Lukas wrote:Okay, after using your script a bit more, I'm certain it would definitely be more useful if the last key would also be deleted if it is 'obsolete'. At all times :)
Yeah, I agree and had been looking into it since your last post. How the script is structured, that's not a quick or easy change. I'll continue to look into it as I have time.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Clean keyframes script?

Post by synthsin75 »

Okay, this script now comes in two flavors:
Regular: https://drive.google.com/uc?export=down ... KF3PStyrT0
This version retains the last keyframe, unless it only finds one key that matches frame zero. So if the channel is unanimated, running it once deletes all but the last key (in case you need it for a hold) and running it again deletes these lone keys (except of split dimension channels).
Severe: https://drive.google.com/uc?export=down ... 0V2wV_X1U-
This version always deletes the last keyframe if it is obsolete (even for split dimension channels).
Last edited by synthsin75 on Fri Sep 01, 2023 1:04 am, edited 1 time in total.
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Clean keyframes script?

Post by Lukas »

Cool, I'll try using them both. This is extremely useful stuff Syn, great work and thanks for sharing!

Edit: I encountered a situation where keys aren't being deleted when they actually should (I think?). See this file. Both the 'Pupil1' and 'Pupil2' bones still have a keyframe at frame 82 after running the severe script. Unless I'm missing something, you'd expect them to get deleted right?
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Clean keyframes script?

Post by synthsin75 »

Updated both. I forgot to handle last step keys.
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Clean keyframes script?

Post by Lukas »

Much appreciated! Tested and works :)
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Clean keyframes script?

Post by Víctor Paredes »

A.Evseeva wrote:Victor, please check the latest version of my keytools script, it has the CLEANUP option, making what, I suppose, You wanted. Unfortunately it does not check bezier handles, but in some cases it can help.
Hi, A.Eseeva
I have been using your script and for both cleaning the animation and also copying and pasting poses in the characters. It's fantastic. Is there any specific thread about your script? I can't find any.
Thanks!
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
A.Evseeva
Posts: 61
Joined: Wed Apr 08, 2015 8:43 am
Contact:

Re: Clean keyframes script?

Post by A.Evseeva »

Víctor Paredes wrote: Is there any specific thread about your script? I can't find any.
It was started here:
http://lostmarble.com/forum/viewtopic.php?f=12&t=31523
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Clean keyframes script?

Post by Víctor Paredes »

A.Evseeva wrote:
Víctor Paredes wrote: Is there any specific thread about your script? I can't find any.
It was started here:
http://lostmarble.com/forum/viewtopic.php?f=12&t=31523
Thanks!
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Clean keyframes script?

Post by Lukas »

Bumped into another exception :shock:

The first 'switch' keyframe remains on the timeline after running the clean keyframes script. I tried A.Evseeva's version, and it skips it there too.

(Edit: Wait...there might just be something wrong with my keys instead (some script created the keys))

(Edit 2: Yep, false alarm. The other script created faulty keys. Ignore this post.)
Post Reply