Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions LINEAR keyframe not linear (extendscript)

  • LINEAR keyframe not linear (extendscript)

    Posted by Roland Tobiasz on November 23, 2019 at 7:52 pm

    I have the following script adding keyframes to a point control effect and then looping through the keyframes and setting them to LINEAR.


    bgAnchor = app.project.item(8).layer("Shape Layer 1").property("Effects").property("Anchor").property("Point");

    var anchTime = new Array([0],[1],[2],[2],[3],[23],[24]);
    var anch = new Array([2700, -1400],[1706.9,1],[1706.9,1],[1706.9,1],[1832.3,1],[1832.2,1],[2700, -1400]);

    bgAnchor.setValuesAtTimes(anchTime, anch);

    for (var k = 1; k<=bgAnchor.numKeys ; k++) {
    bgAnchor.setInterpolationTypeAtKey(k, KeyframeInterpolationType.LINEAR)
    }

    KeyFrames 4 and 5 (@ 3 seconds and @ 23 seconds) have the same value of 1832.3 so I would expect that the values between these two keyframes would be the same but as you can see in the picture below the values drop to approx 1773 in the middle of keyframe 4 and 5 to come back to 1832.3 on keyframe 5:

    This is the setting on keyframes 4 and 5:

    How do I make the values between the 2 linear keyframes be linear and not some form of bezier?

    Roland Tobiasz replied 6 years, 5 months ago 2 Members · 3 Replies
  • 3 Replies
  • Oleg Pirogov

    November 23, 2019 at 11:08 pm

    The setInterpolationTypeAtKey deals with temporal interpolation, while you have auto-bezier for the spatial one. For turning a keyframe’s spatial interpolation to liner I would use setSpatialTangentsAtKey. Like this:


    for (var k = 1; k<=bgAnchor.numKeys ; k++) {
    bgAnchor.setInterpolationTypeAtKey(k, KeyframeInterpolationType.LINEAR);
    bgAnchor.setSpatialTangentsAtKey(k, [0,0,0], [0,0,0]);
    }

  • Roland Tobiasz

    November 24, 2019 at 12:48 am

    Perfect!

    I needed to change the arrays to 2 values and it works perfectly for my project.

    Thank you!

  • Roland Tobiasz

    November 24, 2019 at 12:50 am

    Once again. Thank you Oleg for the solution!

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