Skip to main content
Participant
June 30, 2009
Question

Deleting all keyframes

  • June 30, 2009
  • 3 replies
  • 8014 views

What is the best way to delete all keyframes of a stream? Calling KeyframeSuite3()->AEGP_DeleteKeyframe for every key works, but takes quite a bit of time. I was hoping to just virtually toggle the 'stopwatch' button, but I can't seem to find the API for that.

Any ideas?

This topic has been closed for replies.

3 replies

July 4, 2016

var targetComp = app.project.activeItem; // Collect the active composition
var selectedLayer = targetComp.selectedLayers; // Collect the selected layers
var targetParam = selectedLayer[0].transform.position; // Identify the target parameter

// Delete Keyframes forward
while (targetParam.numKeys != 0) { // While there are still Keyframes, continue looping
  targetParam
.removeKey(1); // Delete the first Keyframe
}

// Delete Keyframes backward

for (i = targetParam.numKeys; i != 0; i--) { // Cycle through the Keyframes
  targetParam
.removeKey(i); // Remove the current Keyframe
}

Inspiring
July 2, 2019

I used this script from UserChangedParam and AE crashed. Anyone else having more luck? The script itself works well when run from ESTK.

July 2, 2019

That's my bad, the script I posted is for ESTK, and it's -slow-

Participant
August 11, 2010

One year later, the idea of doing the deletion backwards helped a lot over here. Thanks!

françois leroy
Inspiring
June 26, 2015

Hi Roy, Hi Shachar,

I finally got a way:

select the keys (I went the script way, much much easier!) and execute command 21 (delete).

for the record, here's my script (mask outline keys here):

string myScript = "myLayer = activeItem.selectedLayers[0]"; //I call the script on parameter change, so I'm sure the selected layer is mine, do differently if it's not the case!!

myScript.append("myMask = myLayer.Masks.property(");

myScript.append(numConvert(myMaskIndex)); // feed the script with my mask index. NumConvert() is just a way to turn a A_long to a string...

myScript.append(");if (myMask.numKeys){myMask.selected = true;app.executeCommand(21);}"); // check if my mask have keyframes, otherwise it will delete my mask!!

ERR(suites.UtilitySuite5()->AEGP_ExecuteScript( plugID, myScript.c_str(), FALSE, NULL, NULL)); // run the script

Pfffew!! Only 6 years to answer a so simple question for a so usefull function... Programming for AE is fun ;-)

Cheers,

François

Community Expert
June 26, 2015

i just finished a 5 year delete operation of 1000000 keyframes with the old

method...

:-D

Community Expert
July 1, 2009

i don't know of a method of deleting all keyframes at once.

however the fastest way i know of is to delete the keyframes from last to first.

it's faster than deleting the first keyframe over and over because the stream's list of doesn't get shifted with each deletion.

if you do find a way to make keyframes go away in one swift operation, please post it here.

i could use that.

:-)

Participant
July 2, 2009

Thanks, I'll give it a shot!