Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How can I change the time of one or some keyframes?

  • Dan Ebberts

    August 22, 2022 at 2:20 pm

    Are you talking about scripting? Unfortunately, you can’t change the time of a keyframe via scripting. You have to create a new keyframe, copy all the attributes of the old one (which can be quite involved and order-sensitive), and delete the old one.

  • Milad Ghiravani

    August 23, 2022 at 7:01 am

    Yes, for scripting!

    Can you help me, what’s this attributes?
    For example on this code:

    var selectedLayers = app.project.activeItem.selectedLayers;
    for (i = 0; i < selectedLayers.length; i++)
    {
    test(selectedLayers[i]);
    }
    function test(thisLayer)
    {
    var spl = thisLayer.selectedProperties.length;
    try
    {
    var selectedKeys = 1;//first keyframe
    var newKeyTime = 2;// secounds 2 for example
    thisKeyValue = thisLayer.selectedProperties[spl-1].keyValue(selectedKeys);
    //*** Add all the attributes But I don't know what?!
    thisLayer.selectedProperties[spl-1].removeKey(selectedKeys);//delete old keyframe
    //*** Copy values to ney keyframe
    thisLayer.selectedProperties[spl-1].setValueAtTime(newKeyTime , thisKeyValue);
    }
    catch (err) {
    alert(err);
    }
    }

    Thank you

  • Dan Ebberts

    August 23, 2022 at 7:48 am

    It’s quite tricky, and it takes a surprising amount of code to do it right. Your best bet might be to get your hands on Jeff Almasol’s rd_Scooter script, which I believe has the code necessary to move keyframes. I think you can still get it from aescripts. The last time I saw it, it was still a .jsx file, not .jsxbin, so you’ll be able to see how he did it.

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