PVC Exclusive | Industry Experts

Free Function Friday retrievePrimaryComps

FFF Header

Welcome to another episode of Free Function Friday. This week we will create a function that will retrieve only the primary compositions of a project file. A composition can contain a variety of layers, including other compositions, aka precomps. So what I mean by primary, is that these compositions are not precomps. For example, if you happen to be working on a feature, the individual shot comps themselves could be primary compositions depending on your workflow. If you had the shot comps gathered in a master timeline for reviewing, then they just became precomps. Some uses for this retrievePrimaryComps function could be to track down the main composition timeline(s) in a messy project, perhaps throw them into a master project folder, or to flag those master compositions for rendering.

You will notice that the layout of this function will look very similar to the collectAllPrecomps function from a few weeks ago. This will be common when running these kinds of processes. They will usually entail similar steps to reach your goal. The ExtendScript object model for After Effects shows you the path to which you can access each area of After Effects. I do an overview of the object model here in the beginning of the video. Literally it’s a road map to navigating the application via scripting. Much like a road map for a city, you travel in a certain direction to reach your end destination. While a city has multiple access streets to some areas, After Effects may only have one or possibly two in most cases. It’s a very small city. 🙂 So in the case of collectAllPrecomps and retrievePrimaryComps, we are traveling to the same destination, but we are just simply looking for two different people when we get there.

If you haven’t done so already there is a Free Function Friday introduction video located here that has some important information pointing to a few resources that will come in handy when scripting for After Effects.

Episode 8 retrievePrimaryComps:


Legal note: The Adobe ExtendScript code talked about in this article and accompanying embedded video(s), and/or graphic images are not guaranteed to be compatible with every version of After Effects. David Torno, ProVideo Coalition, and Diversified will not be held liable for any misuse or incorrect use of the provided ExtendScript code. Use at your own risk.

All of the code I provide in this series, has been created and tested in After Effects CC 2014. Unless otherwise specified in the episode, the code should be compatible with After Effects CS6 through CC 2015. I’ve done my best to avoid depreciated code (code that Adobe removed at some point), and made these functions as compatible as possible. There will however be the occasional piece of code that is brand new as of a certain version of After Effects and therefore will not be backwards compatible from that version. I will mention these if that is the case.

With that said, all the code I provide in this series is open source and free to use in your scripts. I highly encourage you to expand and improve upon the code I provide and start making your own custom functions as well, but please do not repost the code I show in this series as is and claim it as your own. If you use any of the code provided in this series please give credit where credit is due. This series is meant to provide, what I feel is useful code, as well as to hopefully further explain ExtendScript and it’s quirks. While the functions we build throughout this series can perform a task all on their own, they are not meant to be a solo script. How you combine them together and expand upon them is when you will gain the most from these functions.

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

Notify of