Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions can i bake keys every 3 frames?

  • can i bake keys every 3 frames?

    Posted by Dave Leonard on January 14, 2013 at 6:38 pm

    I was wondering if there is a script or native way to select my position keys, and create a keyframe every 3 frames?
    I’ve found something that bakes down the animation to every single key, but I’m looking to skip a few in between.
    Any ideas would be appreciated!

    Declan Smith replied 13 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Declan Smith

    January 16, 2013 at 12:28 am

    This is a very crude script, but would possibly achieve what you want (or at least a starter for 10). The script as it stands assumes that the layer you want to work on is at the top (layer 1). This should probably be changed to loop through all selected layers, I’ll leave that to you. The key part is the script looping through the length of your comp and dropping a keyframe every 3 keyframes. Note that the script as it stands will take account of any running expression when determining the value.

    Hope this helps

    // Set Keyframe Spacing here
    var keyFrameSpacing=3;

    app.beginUndoGroup("Bake Every Third Frame");

    // Looks at activeComp
    var comp=app.project.activeItem;
    // Must be Layer 1 (at the top) - Change this to suit or loop through select layers.
    var layer=comp.layer(1);

    for (i=0;i<comp.duration;i=i+(keyFrameSpacing/comp.frameRate)) {
    // Grab Current Value POST Expression (set to true if you want the value before any expressions)
    bakeValue=layer.position.valueAtTime(i,false);
    // Set New Value
    layer.position.setValueAtTime(i,bakeValue);
    }

    app.endUndoGroup();

    Declan Smith
    https://www.madpanic.tv
    After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase

    “it’s either binary or it’s not”

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy