Skip to main content
Inspiring
November 20, 2019
Answered

sourceRectAtTime and text animation unsync

  • November 20, 2019
  • 3 replies
  • 3879 views

I have a setup where a Rectangle Shape size animates according to a text Animator. The text animates in by animating a Range Selector applied to the Scale property (which is set to 0).

 

This all works well, until I try to move the text layer in time: when the text layer starts later in time, the Shape Layer, still takes the sourceRectAtTime().width as if the text layer was still starting at 00:00:00, resulting in a non sync, and therefore a useless animation.

 

Another strange behavior: when dragging the 'End' value of the Range Selector manually, the Shape follows along, no matter what moment in time. But as soon as it is driven by keyframes or expressions, the unsyncness happens.

 

Does somebody know how to force sourceRectAtTime() to always sample the size of a text layer at the current Composition time?

 

Update: I found that when only the inPoint of the text layer is dragged/trimmed, the expression gets confused. Moving the layer, and then adjust the outPoint to make the duration shorter, keeps the expression working correctly. How can we work around this, to be more flexible?

Correct answer Jaydude-wb

Last night,  Adobe reached out to me with the same anwer as given by Kyle Hamrick.

The secret is that there is a sourceTime for a Text Layer. I wasn’t aware that AE treats text as footage with it's own time.

 

var targetLayer = thisComp.layer("Target Text Layer");

var targetRect = targetLayer.sourceRectAtTime( targetLayer.sourceTime() );

 

[ targetRect.width, targetRect.height ]; // Outputs dimensions for rectangle

3 replies

Jaydude-wbAuthorCorrect answer
Inspiring
November 21, 2019

Last night,  Adobe reached out to me with the same anwer as given by Kyle Hamrick.

The secret is that there is a sourceTime for a Text Layer. I wasn’t aware that AE treats text as footage with it's own time.

 

var targetLayer = thisComp.layer("Target Text Layer");

var targetRect = targetLayer.sourceRectAtTime( targetLayer.sourceTime() );

 

[ targetRect.width, targetRect.height ]; // Outputs dimensions for rectangle

Kyle Hamrick
Community Expert
Community Expert
November 20, 2019

I was actually a little surprised to dig into this myself, but maybe a better way to think of this function is "sourceRectAt *MY* Time."

There's one little addition you could do here that will get you the functionality you're after (and a hat tip to Paul Conigliaro for pointing this out to me):
sourceTime()

 

Give this (or whatever variant is appropriate for your use case) a shot, and you should be in business.

var layer = thisComp.layer("some words");
var rect = layer.sourceRectAtTime(layer.sourceTime());
var x = rect.width;
var y = rect.height;

[x,y]

Inspiring
November 21, 2019

Thanks - that's it! Did not find this solution anywhere.

Mylenium
Legend
November 20, 2019

Nothing stops you from filling in an explicit time statement in the parenthesis, including any statements that may account for shifting in- and out-points or keyframes, e.g. (time-inPoint).

 

Mylenium

Inspiring
November 21, 2019

Yeah, that was my workaround, but for some reason it did not work in all situations:

When a Text Layer is trimmed on the left side, the inPoint trick doesn't work anymore.

Thanks anyway!