ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Autoscale Text Box with fixed height ?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jelle Bonn
Autoscale Text Box with fixed height ?
on Dec 11, 2019 at 10:08:06 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]


Return to posts index

Andrei Popa
Re: Autoscale Text Box with fixed height ?
on Dec 11, 2019 at 2:19:02 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.


Return to posts index

Jelle Bonn
Re: Autoscale Text Box with fixed height ?
on Dec 11, 2019 at 4:38:49 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.


Return to posts index


Patrick Middelkoop
Re: Autoscale Text Box with fixed height ?
on Dec 11, 2019 at 2:19:28 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.


Return to posts index

Andrei Popa
Re: Autoscale Text Box with fixed height ?
on Dec 11, 2019 at 5:11:24 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]