Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions [HELP] Time Remap – Trying to create a Script

  • [HELP] Time Remap – Trying to create a Script

    Posted by Vincenzo Imbimbo on May 25, 2022 at 7:27 pm

    Hello guys! I’m trying to create a script that does this:

    Step 1: Enable Time Remap of a precomp ( or all precomps selected)

    The time remap automatically creates 2 keyframes, so…

    Step 2: Go to the last keyframe and go back 1 frame, create new keyframe and delete the last keframe. Example: a precomp of 10 seconds (25 fps) would have a keyframe on frame 0:00 and another keframe on frame 10:00, i want to create a keyframe on frame 9:24 and delete the keyframe of 10:00. I want this to happen no matter what time duration is that precomp and no matter how fps it is, always create 1 keframe before the last one and delete that last one.

    I now how to do step 1, but only works with 1 layer, i don’t know why is the “for loop” not working, and also i’m having trouble with step 2.

    The code that i have right now is this:

    app.beginUndoGroup("My Script");

    var comp = app.project.activeItem;

    var layers = comp.selectedLayers;

    if(layers.length == 0){

    alert("You must select a layer");

    } else {

    for(var i = 0; i < layers.length; i++){

    layers[i].timeRemapEnabled = true;

    var timeRemapProp = layers[i].property("ADBE Time Remapping");

    var times = [0, //i think here goes something like "outPoint - one frame"?//];

    var values = [0, //i don't now what should i write here//];

    timeRemapProp.setValuesAtTimes(times, values);

    }

    }

    app.endUndoGroup();

    Vincenzo Imbimbo replied 4 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 25, 2022 at 8:17 pm

    Something like this maybe:

    var comp = app.project.activeItem;

    var layers = comp.selectedLayers;

    var timeRemapProp;

    if(layers.length == 0){

    alert("You must select a layer");

    } else {

    for(var i = 0; i < layers.length; i++){

    if (layers[i].canSetTimeRemapEnabled){

    layers[i].timeRemapEnabled = true;

    timeRemapProp = layers[i].property("ADBE Time Remapping");

    timeRemapProp.addKey(timeRemapProp.keyTime(timeRemapProp.numKeys)-comp.frameDuration);

    timeRemapProp.removeKey(timeRemapProp.numKeys);

    }

    }

    }

  • Vincenzo Imbimbo

    May 26, 2022 at 3:46 pm

    Thank you Dan, it works perfectly!

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