Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sourceRectAtTime for paragraph text. Difference between inner and outer bounding box?

  • sourceRectAtTime for paragraph text. Difference between inner and outer bounding box?

    Posted by Jeremy Dance on August 15, 2018 at 3:58 pm

    Here is a video that shows in 6 seconds what I am trying to do

    https://www.reddit.com/r/AfterEffects/comments/97bwuc/ive_used_sourcerectattime_a_lot_however_ive_never/

    I’ve use sourceRectAtTime a lot to resize boxes behind text. It works great. However I’m running into a problem when I use the horizontal text tool, or “paragraph text” as I call it. I’d like to use the constraints of paragraph text and sourceRectAtTime to create a shape layer that scales with the text as it is typed on using the typewriter effect. It seems that there are two bounding boxes for paragraph text, and I don’t know how to access the “inner” bounding box. Let me explain.

    When you use the horizontal (or vertical for that matter) text tool in After Effects, you get a paragraph bounding box that will constrain text to that box. This is what I’m referring to as the “outer” bounding box. If you use sourceRectAtTime to resize a shape layer then it will properly resize to the “outer” bounding box you have set with the horizontal text tool. However, when you click away, After Effects shows another bounding box with only encircles the text on screen. Is there anyway to access the dimensions of this “inner” bounding box? After Effects is already calculating it for user interface reasons. How do I access it?

    //code to access the paragraph bounding box
    watchLayer = thisComp.layer("myParagraphText");
    myHeight = watchLayer.sourceRectAtTime(time-watchLayer.inPoint,true).height;
    heightBuffer = thisLayer.effect("heightBuffer")("Slider");
    myHeight + heightBuffer;

    Jeremy Dance replied 7 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 15, 2018 at 4:13 pm

    Try changing:

    sourceRectAtTime(time-watchLayer.inPoint,true)

    to:

    sourceRectAtTime(time-watchLayer.inPoint,false)

    Dan

  • Jeremy Dance

    August 15, 2018 at 4:25 pm

    Just figured it out. For those wondering, it is possible to access the “inner” bounding box. It is called the extents. If you put false (rather than true as I had done) it will only consider the extent of the text, rather than the extent of the paragraph bounding box.

    watchLayer = thisComp.layer("myParagraphText");
    myHeight = watchLayer.sourceRectAtTime(time-watchLayer.inPoint,false).height;
    heightBuffer = thisLayer.effect("heightBuffer")("Slider");
    myHeight + heightBuffer;

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