ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Remove all keyframes by script

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Xavier Gomez
Remove all keyframes by script
on Jul 10, 2013 at 9:21:51 pm

Hello,
is there a way to remove all keyframes on a given property other than using the removeKey() method ?
I'm thinking about the timeVary stopwatch : from off to on it adds a keyframe (same as addKey()), from on to off it removes them all in a fraction of millisecond, while a removeKey() loop can be very slow.
So: is that stopwatch on ---> off accessible to scripting?

Thank you for any suggestion.

Xavier


Return to posts index

Dan Ebberts
Re: Remove all keyframes by script
on Jul 10, 2013 at 10:26:58 pm

I don't believe so.

Dan



Return to posts index


Mitch Mann
Re: Remove all keyframes by script
on Jul 10, 2013 at 10:44:13 pm

Maybe have the script select all keys on the property, then delete. You could call delete as a menu command. Then you wouldn't have to loop.


Return to posts index


Xavier Gomez
Re: Remove all keyframes by script
on Jul 11, 2013 at 9:46:51 am

Thank you, it works very well. Deletion is instant!

Make sure that the property (and no other) is selected, that the property has keys, then app.executeCommand(21) remove all its keys instantly.

Xavier.


Return to posts index

Xavier Gomez
Re: Remove all keyframes by script
on Jul 11, 2013 at 4:21:10 pm

Hello again, i'm facing another problem.
Just found out that 21 is a dangerous command (!) and better be sure to have focus on the right thing before using it. For instance, running app.executeCommand(21) while the focus is on the project panel will delete all currently selected project items, which is obviously not what was intended.

Is there a way to know that the right composition is opened in the Timeline Panel, and not just selected in the project one ? This to make sure that it's content will be targetted by delete, not the comp itself.

I've read this thread http://forums.creativecow.net/thread/227/23479#24437 which deals with this problem but i don't fully understand it, and I would like to avoid CS6 only abilities such as setActive(). Unlike in the cited thread i know exactly which comp to focus on but i really can't find what string to use for app.findMenuCommand(...).

Thank you for advice.

Xavier.


Return to posts index

Mike Sevigny
Re: Remove all keyframes by script
on Jul 4, 2016 at 3:58:31 pm

This is one of the first things to come up for removing keyframes so I thought I would share a few methods

First identify the parameter with the keyframes:
targetComp = app.project.activeItem; // Collect the active composition
selectedLayer = targetComp.selectedLayers; // Collect the selected layers
targetParam = selectedLayer[0].transform.position; // Target the Position parameter of the first selected layer

Then you can cycle forward through the keyframes and delete them:
while (targetParam.numKeys != 0) { // While there are still Keyframes, cycle through them
targetParam.removeKey(1); // Delete the first Keyframe
}

or cycle backward and delete them:
for (i = targetParam.numKeys; i != 0; i--) { // Cycle through the Keyframes
targetParam.removeKey(i); // Remove the current Keyframe
}


Mike Sevigny
http://www.torusfx.com


Return to posts index


Cole Boscaljon
Re: Remove all keyframes by script
on Jul 25, 2018 at 3:57:11 pm

I'm a bit late to the party (only 5 years). But using a combination of 2 shortcuts (select all keyframes then delete them) it can be done. Not sure if this is what you're looking for, but it may come in handy!

1) Select the layer(s)
2) Push the U key (This will reveal all keyframes on the selected layers)
3) Push Ctrl + Alt + A (This will highlight all keyframes that are showing)
4) Delete (This will delete all selected keyframes)

There is another one for deleting expressions as well. I use this for compositions I've duplicated and no longer want the expressions on. So instead of going through and deleting each expression individually:

0) Assuming all layers inside the composition are collapsed before doing this
1) Select the layer(s)
2) Push the E key twice (Known as EE) (This will also reveal all expressions within the layers selected)
3) Push Ctrl + Alt + A (This will highlight all keyframes that are showing)
4) Push Alt + Shift + = (This will delete all expressions)
5) If you want to get rid all the effects too (Slider expressions or anything else)
6) Ctrl + Shift + E (Deletes all effects)

Hope this helps!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]