SourceRectAtTime() Expression- Adobe After Effects tutorial

The new sourceRectAtTime() can get you the width and height of text and shape layers. It’s new but it’s good. If you have Ae CC 2014.2 (aka 13.2.0.0) then you can enjoy this. If you don’t have that option open and you want to make solids resize to text you should check out an older tutorial on this site.

 

This tutorial also talks for a long time about expressions in general, so if you’re not into that… get out now!

 

This is the expression we wrote on the size:
s=thisComp.layer(“Hello people”);
x=s.sourceRectAtTime(time-s.inPoint,true).width;
y=s.sourceRectAtTime(time-s.inPoint,true).height;
[x,y]

 

This is the expression we wrote on the position:
content(“Rectangle 1”).content(“Rectangle Path 1”).size/2

 

If you have any questions just let me know in the comments.

 

Download this project file:

This file ONLY works in After Effects 13.2 and newer.

Download DirectDownload Via GumRoad
ecabrams
evan.abrams@gmail.com

3 Comments

  • Robert

    21.02.2016 at 02:02 Reply

    I added a wiggle to the anaitmor that was doing 3D position. The mode was Add and I keyed Min 0 at start and finish and then keyed -15 in the middle and it gave and nice little one bounce effect.Not Inertial but not bad!

  • Ze'ev Gilad

    07.12.2016 at 17:08 Reply

    This is great, but is there a way to set the anchor point to the absolute center or corner of the region? It seems to have 0,0 at the bottom of the first row of text, whose height is arbitrary based on font and size.

    • ecabrams

      07.12.2016 at 17:15 Reply

      Hey Ze’ev. First, the anchor point is certainly not “arbitrary”. The anchor point for text is based on the paragraph settings and located at the baseline in keeping with the paragraph settings. You could use the sourceRectAtTime to relocate that anchor point into the middle centre of a layer if you wanted. You would simply need to move it to the average of the height and width right?

Post a Comment