Copy link to clipboard
Copied
Hi AE wizards!
I am trying to create a simple lowerthird .morgrt with the top text layer and bottom text layer in one text box. So when people use the template to change the text, the text box will resize accoring the whichever text line is longer. Text is left aligned and the height of the box is fixed so only the width needs to adjust to the right. Font size is also not adjustable.
I am familiar with the below expressions for a single text layer. I am wondering if it is possible to manipulate this to adjust to two layers instead?
Shape layer expressions:
Size property:
s = thisComp.layer("Firstname Last Name");
w=s.sourceRectAtTime().width;
h=s.sourceRectAtTime().height;
[w,h]
Position property:
s=thisComp.layer("Firstname Last Name")
w=s.sourceRectAtTime().width/2;
h=s.sourceRectAtTime().height/2;
l=s.sourceRectAtTime().left;
t=s.sourceRectAtTime().top;
[w+l,h+t]
Here is what I have experimented with two layers but I keep getting an error in the expressions on the position property. Also the box fits the two lines of text but with no leading between lines.
Here is the code in the above screen shot
Size property:
s=thisComp.layer("Name");
t=thisComp.layer("Job");
s_w=s.sourceRectAtTime().width;
s_h=s.sourceRectAtTime().height;
t_w=t.sourceRectAtTime().width;
t_h=t.sourceRectAtTime().height;
w=Math.max (s_w, t_w);
h = (s_h+t_h);
[w,h]
Position property:
w=s.sourceRectAtTime().width/2;
h=s.sourceRectAtTime().height/2;
l=s.sourceRectAtTime().left;
t=s.sourceRectAtTime().top;
[w+l,h+t]
I am a real novice at expressions! Any help would be much appreciated.
Copy link to clipboard
Copied
In your position expression, you haven't defined what s is (like you did in the size expression). Also, I think your position expression will need to account for whichever line is the longest, as your modified size expression does.
Copy link to clipboard
Copied
Thank you! Updated the position expression and the error is gone! Huge help. New expression below.
s=thisComp.layer("Name");
t=thisComp.layer("Job");
l=s.sourceRectAtTime().left;
t=s.sourceRectAtTime().top;
s_w=s.sourceRectAtTime().width/2;
s_h=s.sourceRectAtTime().height/2;
t_w=s.sourceRectAtTime().width/2;
t_h=s.sourceRectAtTime().height/2;
s_l=s.sourceRectAtTime().left;
s_t=s.sourceRectAtTime().top;
t_l=s.sourceRectAtTime().left;
t_t=s.sourceRectAtTime().top;
w=Math.max (s_w, t_w);
h = (s_h+t_h);
[w+l,h+t]