Free Function Friday fillCompWithShape
Welcome to Free Function Friday. Today marks the 40th and final episode in the series. It’s hard to believe that when I first started drafting up the idea for Free Function Friday in March of 2014, that it would be this large. Recording of episodes started in September of 2015, at which point I had already designed the opening title template, and was churning out title cards each night after work. I had built a stockpile of episodes to prepare for the weekly release schedule. There were twenty-four episodes all set for release when the series premiered on October 2, 2015. It was a mad dash after that point, with some episodes being recored and posted just hours before public release. 🙂
So much has changed in my life during this series, I’ve moved, gotten married, changed jobs, and have worked countless hours putting this whole series together. While this is the end of the series, it is far from the end of my contribution to the community. I have big stuff already being planned as I type this, but for the moment I will rest and take in the sunshine.
Everyone in the After Effects community has been amazing, and I thank you from the bottom of my heart for all of the support, and collective participation that has been made. I hope you have learned and continue to keep learning.
Ok, enough of the babbling, and on to the final episode. fillCompWithShape is a more aggressive function than we’ve built in the past. So much so that the tutorial is just under and hour. Apologies, it could have gone way longer though easily. We go though a few different areas of shape path data. Now this is a slight bit different than the mask shape data we dealt with in getMaskPaths and setMaskPaths, as we are creating actual Shape Layers for this one. There are three nested functions being created for this function as well, but don’t worry they are very small. What fillCompWithShape effectively does is take mask shape data, along with a few other arguments and randomly copies the shape path within the comp 2D space as Shape Layers. You can supply a copy count, color palette, and set various layer attributes as the new Shape Layer is created. I originally used this code in a high profile project to create a series of animated triangles earlier in the year. This code is a paired down simplified version, that is a bit easier to customize hopefully.
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 40 fillCompWithShape: (IMPORTANT NOTE: Function is built to only handle one mask shape, even though getMaskPaths is capable of gathering multiple mask paths)
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.