Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Connecting Two Keyframes To Start And End Point of Workspace

  • Dan Ebberts

    February 6, 2022 at 6:48 pm

    Do you mean the work area? Expressions don’t have access to the work area start and end times. Scripting does, so you could do it with a script, but it wouldn’t adjust automatically when you change the work area.

  • Kamiar Babaei

    February 6, 2022 at 7:00 pm

    Yes, work area,

    Than maybe the script can have a refresh button for when I want to update it to the new work area length?

  • Dan Ebberts

    February 6, 2022 at 7:54 pm

    It could, but that would require a UI for the script, which is a bit of work. Here’s how the basic functionality might look though:

    function setKF(){

    var myComp = app.project.activeItem;

    if (! (myComp && (myComp instanceof CompItem))){

    alert("No comp active.");

    return;

    }

    var myProps = myComp.selectedProperties;

    if (myProps.length == 0){

    alert("No property selected.");

    return;

    }

    var myProp = null;

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

    if (myProps[i].numKeys >= 2){

    myProp = myProps[i];

    break;

    }

    }

    if (myProp == null){

    alert ("No property with 2 or more keyframes selected.");

    return;

    }

    var tStart = myComp.workAreaStart;

    var tEnd = tStart + myComp.workAreaDuration;

    var myExpr = "t = linear(time," + tStart + "," + tEnd + ",key(1).time,key(numKeys).time);\rvalueAtTime(t)";

    myProp.expression = myExpr;

    }

    setKF();

  • Kamiar Babaei

    February 7, 2022 at 10:22 am

    Thank you so much.

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