Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sourceRectAtTime always returning full size of text layer

  • sourceRectAtTime always returning full size of text layer

    Posted by Ernest Rosado on December 19, 2020 at 9:02 pm

    Hi all,

    I’m trying to dynamically size a shape layer as a background for a text layer.

    However I want this text layer to type itself out word-by-word, so I’m using an opacity animator on the layer.

    But it seems as if the .SourceRectAtTime function is returning the full size of the text layer even before the words have appeared via the animator. I want the shape layer to only be the size of the portion of text that has already appeared.

    Is there another function I should be using instead of SourceRectAtTime?

    Ultimately this is going to be for a mogrt file otherwise I’d just hand-animate the shape layer, but I need to do it procedurally for this project.

    Thanks

    Filip Vandueren replied 5 years, 4 months ago 4 Members · 7 Replies
  • 7 Replies
  • Ernest Rosado

    December 19, 2020 at 11:36 pm

    Just a quick update, my script works properly (using sourceRectAtTime) if I use a different animator, like a scale animator. Just not opacity, which is really the effect I was going for. Is there any hope?

  • Chris Voelz

    December 22, 2020 at 7:43 pm

    Are you using a text box? If so this would be the expected behavior. Try converting the text layer to point text.

  • Filip Vandueren

    December 23, 2020 at 4:01 pm

    Correct, invisible characters (opacity=0) still count for the sourceRect, the fix is to scale them to 0% so they don’t take up any space.

    You should set the smoothness of the scale animator to 0 so it doesn’t scale the letters up, they’re only ever 0 or 100% nothing inbetween.

  • Ernest Rosado

    December 24, 2020 at 5:19 pm

    Thank you both for the replies.

    I ended up finding an old script that apparently was used prior to the existence of sourceRectAtTime that physically scans for pixels to return an accurate sourceRect even when the characters have an opacity of 0. It renders slow as hell but it works.

  • Vahab San

    December 24, 2020 at 8:14 pm

    Maybe a trick is to use two text layers with linked text source, on the parent layer’s animator set up a scale property and on the child layer’s animator set opacity, link selectors of both animators and turn the scaled layer’s visibility off. Then, of course, take the sourceRectAtTime from this text layer.

  • Ernest Rosado

    December 24, 2020 at 11:20 pm

    Interesting concept! Would the fact that the layer’s visibility is off change the result of sourceRectAtTime? I’ll have to experiment with this. Thanks for the idea!

  • Filip Vandueren

    December 28, 2020 at 7:27 pm

    No, the visibility doesn’t matter.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy