Free Function Friday Ep.35 – removeKeyframes

May 20th 2016 08:00:41am

Welcome to Free Function Friday episode 34 removeKeyframes. Two weeks ago we built a function for getting keyframes called getKeysBasic, this week we remove them. While not an ideal method, the removeKey() method does work, I just think it wasn’t made with the idea of removing hundreds of keyframes at once in mind.

It’s very sluggish when dealing with properties that have a keyframe on every frame. These can be when you bake an expression on a property, or you’ve imported a moving object from a 3D track. If you plan on using this on lots of layers that have lots of keyframes, just be prepared for a processing hit.

Source Code:

var prop1 = app.project.activeItem.layer(1).property("ADBE Transform Group").property("Position");

removeKeyframes(prop1);
/*	TESTING ABOVE	*/

function removeKeyframes(propertyInput){
	if(propertyInput instanceof Property){
		while(propertyInput.numKeys > 0){
			propertyInput.removeKey(1);
		}
	}
}
Checkout more:
After Effects ExtendScript Training: Ep. 3
X-Particles Polygon Disintegration
Expression Shorts Auto Layer Offset 2D
After Effects ExtendScript Training: Ep. 10
Advanced 2D Face Replacement