ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

LINEAR keyframe not linear (extendscript)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Roland Tobiasz
LINEAR keyframe not linear (extendscript)
on Nov 23, 2019 at 7:52:40 pm
Last Edited By Roland Tobiasz on Nov 23, 2019 at 7:56:24 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?


Return to posts index

Oleg Pirogov
Re: LINEAR keyframe not linear (extendscript)
on Nov 23, 2019 at 11:08: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]);
}


Return to posts index

Roland Tobiasz
Re: LINEAR keyframe not linear (extendscript)
on Nov 24, 2019 at 12:48:51 am

Perfect!

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

Thank you!


Return to posts index


Roland Tobiasz
Re: LINEAR keyframe not linear (extendscript)
on Nov 24, 2019 at 12:50:50 am

Once again. Thank you Oleg for the solution!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]