Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Issues with SourceRectAtTime not match the height of my text

  • Issues with SourceRectAtTime not match the height of my text

    Posted by Emma Beinish on February 26, 2024 at 2:46 pm

    Hi everyone,

    I’m issues with my shape layer not matching the height of my text. I’m using the paragraph text mode.
    Here’s the expression I’m using for the shape layer size:

    textWidth=thisComp.layer(“Saturday Night Live host, Timothée Chalamet, rode away with the show on his beloved tiny horse”).sourceRectAtTime().width;

    textHeight=thisComp.layer(“Saturday Night Live host, Timothée Chalamet, rode away with the show on his beloved tiny horse”).sourceRectAtTime().height;

    [490.2, textHeight]

    I’ll also attach some screenshots with other additional expressions I’ve used.

    Thank you 🙏

    Andrei Popa replied 2 years, 7 months ago 3 Members · 2 Replies
  • 2 Replies
  • Tom Morton

    February 28, 2024 at 7:14 am

    Can’t see an obvious problem with your script. Personally I would rename the text layers to something short and simple to help keep your code clean.

    If the sourceRectattime() functions aren’t returning the right answer, you’re probably using a text box, don’t think it works on these, it has to be free form text – open the text type tool, and don’t click and drag to make a box, just click anywhere instead.

  • Andrei Popa

    February 28, 2024 at 7:45 am

    You need to add parameters to the function like this:

    textWidth=thisComp.layer(“Saturday Night Live host, Timothée Chalamet, rode away with the show on his beloved tiny horse”).sourceRectAtTime(time, false).width;

    Also, sourceRectAtTime does not count for scale, so your final expression may look like this

    textWidth=thisComp.layer(“Saturday Night Live host, Timothée Chalamet, rode away with the show on his beloved tiny horse”).sourceRectAtTime(time, false).width * scale[0] * 0.01;

    textHeight=thisComp.layer(“Saturday Night Live host, Timothée Chalamet, rode away with the show on his beloved tiny horse”).sourceRectAtTime(<i style=”font-family: inherit; font-size: inherit; color: var(–bb-body-text-color);”>time, false<i style=”background-color: var(–bb-content-background-color); font-family: inherit; font-size: inherit; color: var(–bb-body-text-color);”>).height <i style=”font-family: inherit; font-size: inherit; color: var(–bb-body-text-color);”>* scale[1] * 0.01<i style=”font-family: inherit; font-size: inherit; color: var(–bb-body-text-color); background-color: var(–bb-content-background-color);”>;

    [490.2, textHeight]

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