Copy link to clipboard
Copied
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?
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.source
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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]
Copy link to clipboard
Copied
Thanks - that's it! Did not find this solution anywhere.
Copy link to clipboard
Copied
I've come from the future to thank you for this insight. I had no idea text layers were considered footage with sources. The sourceTime(time) function seems similar in basic use to toWorld(position), and saved me when using markers for mask and text animators.
Copy link to clipboard
Copied
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