Adobe Creative Cloud

Digital Video & Audio

favorite features in CC versions of After Effects: expression access to dynamic layer bounds, including text layers

In the After Effects CC 2014 (13.2) update, we added several scripting and expression enhancements to make working with text easier.

My favorite of these enhancements is the addition of an expression method with which you can read the rectangle bounds of a layer’s content, including the corrected bounds of a text layer, for any time in a composition. The sourceRectAtTime method from the After Effects scripting API is now accessible in expressions as a read-only layer object attribute. The values returned are calculated before effects and layer styles are applied.

When I asked folks recently who was using this new method and how, I got a lot of responses from folks who are now able to create lower thirds, credit scrolls, and other text animations much more easily because they are able to have various graphical elements laid out according to the width and height of a block of text, even when that block of text is changing. One example is Victoria Nece’s new script, which uses this expression method to automatically lay out credit scrolls.

Here’s Evan Abrams showing how to use this in a video on YouTube:

Here are the technical bits:

layer.sourceRectAtTime(t = time, includeExtents = false)

  • t: the time index, in seconds. A floating-point value.
  • includeExtents: true to include the extents, false otherwise. Extents apply to shape layers only, increasing the size of the layer bounds as necessary.

Returns a JavaScript object with four attributes: [top, left, width, height]

Example usage for a text layer named myTextLayer:

// Returns width value at the current time as a number
var textLayerWidth =  myTextLayer.sourceRectAtTime().width;

Go ahead and try this out now in the current version. If you’re not already a Creative Cloud subscriber, you can try the free 30-day trial. For information about purchasing a Creative Cloud subscription, see this page about plans and this page with current promotional offers.

If you want to let us know what your favorite changes in After Effects have been since After Effects CC (12.0), come and tell us here, whether your favorite change is a new feature, a bug fix, or a little tweak in behavior.

After Effects, General, Region of Interest