How to clear all keys of a property

Moderator: Paul Tuersley

Post Reply
Posts: 4
Joined: December 16th, 2021, 6:07 am
Location: Shanghai

I know I can clear all keys of a property through the following code:

Code: Select all

    for (var index = property.numKeys; index >=1; index--) {

However, when I actually practise it, it consumes quite a long time, if the property has many keys. I don't know why it is so time-consuming. If I manually click the clock button in the AE instead of using the code, it can be quickly done.
So is there any method to quickly clear all markers of a property?

Posts: 1
Joined: July 19th, 2023, 6:58 am

A faster way to do this would be to select the keyframes you want to delete and execute the in-app "Delete" command

something like this:

Code: Select all

app.executeCommand(2004); //use this to make sure nothing is selected, in-app deselect all command
property.selected = true; //select the property, this also selects all the keyframes of that property
app.executeCommand(21); //in-app clear command

This is way faster than deleting the keyframes using a loop.

great list of other in-app comands here:

Post Reply