After Effects ExtendScript Training: Ep. 15 Part 1 & 2

ExtendScript Script Writing Training

Update: 3/19/2017 Added code fix download

Welcome to episode 15 of the After Effects ExtendScript Training series. This week, it’s keyframes, keyframes, keyframes. Back in episodes 4, 5, and 6, we went over reading values and setting values on various project items and layer properties, but we never took that step down into the next level of the hierarchy and talk about keyframes. The fact of the matter was that keyframes are and are not as straight forward as you may think. Because of this, it was necessary to give keyframes their own episode. Which quickly became a two part episode as well. We will go through and manually create standard keyframes on a property, read keyframe values from a property, as well as transfer keyframes from one layer property to another layer property. This will also involve building some handy functions which will allow us to deal with standard, hold, ease and roving keyframes. We have lots to go over, so let’s get started.

If you missed any of the previous episodes in this series, follow the links below.

Episode 1 (Intro)

Episode 2 (Javascript Basics p1)

Episode 3 (Javascript Basics p2)

Episode 4 (After Effects Object Model structure overview / Script Preparation and development tips / Single Item Access of various project items, comps and layers)

Episode 5 (Access Renderqueue items, output modules and file paths / Multiple item access of project items, comps and layers / Batch change all renderqueue items file paths)

Episode 6 (Collecting data into an Array() / Changing values / Various tips)

Episode 7 (Create new comps and folders / Create Null, Solid, and Text layers)

Episode 8 (Create multiple comps of various sizes / Use Undo group / Add solids to match each comp / Various tips)

Episode 9 (Globally change blue solids to red / Replace solid name blue with red)

Episode 10 (Build a custom function to collect all CompItem objects / Modify function to dynamically allow for choice of CompItem, FolderItem or FootageItem)

Episode 11 (Build floating GUI)

Episode 12 Part 1 & 2 (Build dockable/floating combo GUI)

Episode 13 (ExtendScript Developer Utility script / Retrieve list of project item footage file paths)

Episode 14 (Processing text strings)

In this episode:
– Create keyframes
– Read keyframe values
– Set keyframe values
– Create function to collect all keyframes on a property (Key types: Hold, Easy Ease, Ease In, Ease Out, Roving)
– Create function to transfer keyframes to another layer (Key types: Hold, Easy Ease, Ease In, Ease Out, Roving)

****This particular episode appears to have a few code mistakes on my part and needed some updating as it has been confusing some users when trying to learn it. I appologize for the headaches it may have caused. I have recently, with the help of viewers, corrected the code and have decided to provide a zipped JSX of that corrected code here: AEES_EP15_Keyframes_CodeFix

Still watch the video for most of the explanation on doing this, but please read through the JSX for notes that will explain what each part is doing.

Was This Post Helpful:

0 votes, 0 avg. rating

Support ProVideo Coalition
Shop with Filmtools Logo

Share Our Article

David Torno is a Visual Effects professional based in Los Angeles, California. His work over the years has included commercials, feature films, music videos, and multimedia projects. During his free time, David enjoys expanding his…

Leave a Reply

2 Comment threads
4 Thread replies
Most reacted comment
Hottest comment thread
4 Comment authors
David TornoRainier RaydanDavid TornoDavid TornoAnna Komarova Recent comment authors
newest oldest most voted
Notify of
Anna Komarova
Anna Komarova

Hello, David! I really appreciate your lessons, they are supercool! However I didn’t get correct result for bezier and roving keyframes. So I with my colleague did some research and added a couple of lines of code. First, we noticed that ie and oe variables, responsible for temporal ease, aren’t being used in transferKeys function. So we added extra if construction in the loop in transferKeys function: if(keysArray[k].inin != KeyframeInterpolationType.HOLD || keysArray[k].outin != KeyframeInterpolationType.HOLD){ propertyInput.setTemporalEaseAtKey(newKeyIndex, keysArray[k].ie, keysArray[k].oe); } Second, we set rov for all new keyframes = false, because roving keyframe can’t be last keyframe. After creating all keyframes we… Read more »

David Torno
David Torno

Thanks Anna, I appreciate the kind words. You are correct, there are a few bugs in this code. This was mentioned once before, a long time ago, in the comments, but I guess has been lost during the last PVC site transition. Thank you for drafting up a solution and posting it here. Should help even more for viewers. Thanks.

Rainier Raydan
Rainier Raydan

Hi! I’m having problems with the time remap property. I cant get it to work… is there a solution with those keyframes? Thanks!