ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Bumpy position keys

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Serge Marcotte
Bumpy position keys
on Jan 28, 2009 at 5:05:51 pm

Hello - I have some bumpy position keyframes along a 1000-frame layer. The Smoother isn't working as well as I would hope. Is there an expression that could delete every second key for me? I have a feeling that would help a good deal. Thanks very much.



Return to posts index

Dan Ebberts
Re: Bumpy position keys
on Jan 28, 2009 at 6:04:45 pm

An expression to ignore every other keyframe would be tricky, but this script should remove all even numbered keys for you:

{
var myComp = app.project.activeItem;
if (myComp && myComp instanceof CompItem){
var myLayers = myComp.selectedLayers;
if (myLayers.length > 0){
var myLayer = myLayers[0];
var myProperty = myLayer.property("Position");
for (var i = myProperty.numKeys; i > 0; i--){
if (i%2 == 0) myProperty.removeKey(i);
}
}else{
alert("No layer selected");
}
}else{
alert ("No comp selected");
}
}

Just save it as a .jsx file, make sure your layer is selected, then File > Scripts > Run Script File and navigate to the script.

Dan



Return to posts index

Serge Marcotte
Re: Bumpy position keys
on Jan 28, 2009 at 6:13:51 pm

OK - That's impressive. Just like that, off the top of your head. And it works.



Return to posts index


Jhem Murray
Re: Bumpy position keys
on Jun 4, 2013 at 4:24:51 pm

Dan you are a legend...how do you know all this stuff? incredible...


Return to posts index

Navarro Parker
Re: Bumpy position keys
on Feb 1, 2017 at 2:16:11 am

Hey Dan!

I just applied this to an auto-traced mask and it didn't remove any keyframes. Are mask KFs something different?


Return to posts index

Dan Ebberts
Re: Bumpy position keys
on Feb 1, 2017 at 4:14:48 am

It should work if you change this line to point to the property with the keyframes:

var myProperty = myLayer.property("Position");


Dan



Return to posts index

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