How to clear all keys of a property

Moderator: Paul Tuersley

Post Reply
SolidBlock
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--) {
        property.removeKey(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?

Nishant
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: https://hyperbrew.co/blog/after-effects-command-ids/

User avatar
evefalcao
Posts: 4
Joined: December 25th, 2016, 12:27 pm
Contact:

The executeCommand function is significantly faster for this task:
Attachments
loopTest1.png
loopTest1.png (16.81 KiB) Viewed 3863 times
Post Reply