Free Function Friday removeUnusedEffects
Welcome to episode 30 of the Free Function Friday series. This function is large enough that it warrants two nested functions to streamline the process. The combination of these two function will return index data for the comp, layer, and effect to be removed. This data will then be processed by the main function to do the removal.
There will be a few scenarios to code for in this function, all relating to how a plugin is determined to be unused. This can be as simple as the plugin effect icon being turned off, thereby preventing it from rendering on a layer. It can also be something more complicated as a layer that is turned off, but happens to be a Track Matte, therefore making plugins still in possible use. We will need to keep this all in mind as we code because it all effects the process of how we build this function. The more organized we are with it, the easier it will be to build. this episode is definitely on of the longest we’ve had in this series so far coming in at just over 53 minutes. I tried to get through as fast as I could, but there is just a lot on content for it. Good side, you only have to build it once. Right? 🙂 Being hands on like this and actually writing the code helps the learning process. Repetition, while annoying at times, does help it sink into the brain. With that, I will let you get onto the video.
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 30 removeUnusedEffects:
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 Moviola 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.