Welcome to episode 24 of the Free Function Friday series. Today we go over how to collect all of the SolidSource objects in your project. One little thing to keep in mind with After Effects though is that Null layers are also technically SolidSource objects as well. So while the Null layer object acts as a null, it’s source is a solid and will read like one in the project panel. I’ve already gone down the road of trying to differentiate the two and while it can sort of be done, it’s not a fast process. It can also only be performed on Nulls that are actively being used in a comp. If a Null layer has been deleted from a comp and only exists as an asset in the Project Panel, then it is now solely a SolidSource object and it cannot be determined if it was created as a Null initially. Unless the default name still has “Null” in it, but that would not be a long term reliable system since the user can change that name at any point. For the Nulls still being used in a comp, you will need to loop through every single comp in your entire project and check every single layer to see if that layer object is a null layer. layerObject
.isNull;. Then you grab the source of that layer and proceed to exclude it or include it in another array depending on your needs. I’m not going to go over that today though, as I am trying to keep these videos as short and direct as I can.
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 24 collectAllSolids:
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.