Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Autoscale Text Box with fixed height ?

  • Autoscale Text Box with fixed height ?

    Posted by Jelle Bonn on December 11, 2019 at 10:08 am

    I managed to make a dynamic box with the code below where when you change the text and it automatically resizes to fit the box.

    The problem however is that when I have letters like ‘y’, ‘p’, ‘q’, ‘Q’, the box height becomes larger and I dont want this. I want to have a fixed heeight because I have an animation with a white line next to my box and their height should be the same.

    How can I resolve this? Thanks.

    SIZE
    s=thisComp.layer("1 - Name LastName");
    w=s.sourceRectAtTime().width;
    h=s.sourceRectAtTime().height;
    [w,h]

    POSITION
    s=thisComp.layer("1 - Name LastName");
    w=s.sourceRectAtTime().width/2;
    h=s.sourceRectAtTime().height/2;
    l=s.sourceRectAtTime().left;
    t=s.sourceRectAtTime().top;
    [w+l,h+t]

    Andrei Popa replied 6 years, 8 months ago 3 Members · 4 Replies
  • 4 Replies
  • Andrei Popa

    December 11, 2019 at 2:19 pm

    Would modifying the white box accordingly bee a problem? So when you have Q’s, the white box would also be higher?

    Andrei
    My Envato portfolio.

  • Patrick Middelkoop

    December 11, 2019 at 2:19 pm

    Hi Jelle!

    You can in fact fix this very simple.

    In the Size-expression you can change the `h` to `value[1]`

    So it would look something like this:


    SIZE
    s=thisComp.layer("1 - Name LastName");
    w=s.sourceRectAtTime().width;
    h=s.sourceRectAtTime().height;
    [w, value[1]]

    POSITION
    s=thisComp.layer("1 - Name LastName");
    w=s.sourceRectAtTime().width/2;
    h=s.sourceRectAtTime().height/2;
    l=s.sourceRectAtTime().left;
    t=s.sourceRectAtTime().top;
    [w+l,h+t]

    This will now fix the standard height to the value you set it in After Effects itself.

  • Jelle Bonn

    December 11, 2019 at 4:38 pm

    I’m making this lower third (template) to use on different video’s, and I need them to be on the exact same position in every video. So I can’t change the height of my white line. I am searching a way to give my blue box a fixed height even when I use letters like ‘Q’ that takes more space.

  • Andrei Popa

    December 11, 2019 at 5:11 pm

    If it’s only the horizontal size that you want modified, you can use this expression for size and set the vertical size to one that fits your text manually.


    //SIZE
    s=thisComp.layer("1 - Name LastName");
    w=s.sourceRectAtTime().width;
    [w,value[1]]

    Andrei
    My Envato portfolio.

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