Expressions: //size margin = 50; w = (thisComp.layer("TEXT").sourceRectAtTime().width)+margin*2; h = (thisComp.layer("TEXT").sourceRectAtTime().height)+margin*2; [w, h] //left text position content("Rectangle 1").content("Rectangle Path 1").size/2 //right text position content("Rectangle 1").content("Rectangle Path 1").size/-2 //centred text position margin = 50; w = (thisComp.layer("TEXT").sourceRectAtTime().width) + margin * 2; h = (thisComp.layer("TEXT").sourceRectAtTime().height) + margin * 2; x = thisComp.layer("TEXT").transform.position[0]; // Centered on the text layer y = thisComp.layer("TEXT").transform.position[1] + h / 2; // Adjusting Y to move downwards [x, y]
This is super helpful.Thank you so much! I have a question: Is there a way to put in different margins? E.g. Top and Bottom have the same and left and right are different?
First-time viewer! Nice flow of explanation. Question: Is there a way I can type paragraph text that fits within a box and is all neatly aligned? . Right now I just type out text and hit enter and some character lines are longer than others so it makes it more disorganize and unbalanced.
Great tutorial! How would the expressions be if I only want the width of the box to adjust with the text, but not the height? The reason is I'm creating a template for lower thirds, and I don't want the height of the box to change when there are letters that go lower, like g, j, etc. I basically want the height of the box to stay constant.
In this case you would need to change the expression in the size property. Try the below, which will use the current value you have set for the shape layer's height, which you can adjust to your preferred size: margin = 50; w = (thisComp.layer("TEXT").sourceRectAtTime().width)+margin*2; h = value[1]; [w, h]
@@MotionCaddy Thanks for your reply! I'm still struggling to make this work. The original expression for the box size was: margin = 20; text_width = thisComp.layer("Text").sourceRectAtTime().width; text_height = thisComp.layer("Text").sourceRectAtTime().height; box_width = text_width + margin*9; box_height = text_height + margin*2; [box_width, box_height] Is that the expression I need to replace with the one in your reply? I tried, but the box still shifts..
I can't get it to work with multiple rows. It doesn't expand equally on top and bottom. The ancor point remains on the first row (I think this is the problem) is there a fix for that?
Thank you for pointing this out! It took a bit of time, but I figured out that I missed an expression needed in the shape layer's position when the text is center-aligned. Here’s the updated expression to put in the Position property of your shape layer: margin = 50; w = (thisComp.layer("TEXT").sourceRectAtTime().width) + margin * 2; h = (thisComp.layer("TEXT").sourceRectAtTime().height) + margin * 2; x = thisComp.layer("TEXT").transform.position[0]; // Centered on the text layer y = thisComp.layer("TEXT").transform.position[1] + h / 2; // Adjusting Y to move downwards [x, y] This adjustment should help keep the shape layer expanding downward as you add new lines. If you have any more questions, feel free to ask!
Thank you, very useful video🔥❤ I have a question: if we want to duplicate the text and the shape layer, the expression needs to be rewritten every time, but is there a way to duplicate the layers so that you don't have to change the expression every time?
Use thisComp.layer(index-1)... instead of the layer name. That way, the sizing information is taken from the layer directly above the one that uses the expression (e.g. if the expression is used in layer 2, it takes the layer with index 2 - 1 as the reference). Then all you have to do is keep the corresponding text & shape layers in the correct order. i.e. Box 1's layer has to be directly below Text 1's layer in the timeline. If there is another layer in between those two layers, it does not work.
Yeah, this. I quickly found that if you have lowercase text with descenders (or not) it reshapes the box accordingly. But I of course want the same height regardless of which letters I input...
I haven't done this myself but I believe the answer is yes, you can export this as a MOGRT file. You’ll need to make sure the expression is fully compatible with Essential Graphics. Just add the controls you want to adjust (like text or shape properties) to the Essential Graphics panel, then export it as a MOGRT.
Expressions:
//size
margin = 50;
w = (thisComp.layer("TEXT").sourceRectAtTime().width)+margin*2;
h = (thisComp.layer("TEXT").sourceRectAtTime().height)+margin*2;
[w, h]
//left text position
content("Rectangle 1").content("Rectangle Path 1").size/2
//right text position
content("Rectangle 1").content("Rectangle Path 1").size/-2
//centred text position
margin = 50;
w = (thisComp.layer("TEXT").sourceRectAtTime().width) + margin * 2;
h = (thisComp.layer("TEXT").sourceRectAtTime().height) + margin * 2;
x = thisComp.layer("TEXT").transform.position[0]; // Centered on the text layer
y = thisComp.layer("TEXT").transform.position[1] + h / 2; // Adjusting Y to move downwards
[x, y]
This is super helpful.Thank you so much! I have a question: Is there a way to put in different margins? E.g. Top and Bottom have the same and left and right are different?
thanks a ton: super helpful + concise!
Glad it was helpful!
thanks very much for this man, if i want to have a separate shape for each line what should i do? please 🙏
First-time viewer! Nice flow of explanation. Question: Is there a way I can type paragraph text that fits within a box and is all neatly aligned? . Right now I just type out text and hit enter and some character lines are longer than others so it makes it more disorganize and unbalanced.
Great tutorial! How would the expressions be if I only want the width of the box to adjust with the text, but not the height? The reason is I'm creating a template for lower thirds, and I don't want the height of the box to change when there are letters that go lower, like g, j, etc. I basically want the height of the box to stay constant.
In this case you would need to change the expression in the size property.
Try the below, which will use the current value you have set for the shape layer's height, which you can adjust to your preferred size:
margin = 50;
w = (thisComp.layer("TEXT").sourceRectAtTime().width)+margin*2;
h = value[1];
[w, h]
@@MotionCaddy Thanks for your reply! I'm still struggling to make this work. The original expression for the box size was:
margin = 20;
text_width = thisComp.layer("Text").sourceRectAtTime().width;
text_height = thisComp.layer("Text").sourceRectAtTime().height;
box_width = text_width + margin*9;
box_height = text_height + margin*2;
[box_width, box_height]
Is that the expression I need to replace with the one in your reply? I tried, but the box still shifts..
can you animate the size of the text and then the shapes follow the size of the letters?
I can't get it to work with multiple rows. It doesn't expand equally on top and bottom. The ancor point remains on the first row (I think this is the problem) is there a fix for that?
Thank you for pointing this out! It took a bit of time, but I figured out that I missed an expression needed in the shape layer's position when the text is center-aligned. Here’s the updated expression to put in the Position property of your shape layer:
margin = 50;
w = (thisComp.layer("TEXT").sourceRectAtTime().width) + margin * 2;
h = (thisComp.layer("TEXT").sourceRectAtTime().height) + margin * 2;
x = thisComp.layer("TEXT").transform.position[0]; // Centered on the text layer
y = thisComp.layer("TEXT").transform.position[1] + h / 2; // Adjusting Y to move downwards
[x, y]
This adjustment should help keep the shape layer expanding downward as you add new lines. If you have any more questions, feel free to ask!
Thank you, very useful video🔥❤ I have a question: if we want to duplicate the text and the shape layer, the expression needs to be rewritten every time, but is there a way to duplicate the layers so that you don't have to change the expression every time?
Use thisComp.layer(index-1)... instead of the layer name.
That way, the sizing information is taken from the layer directly above the one that uses the expression (e.g. if the expression is used in layer 2, it takes the layer with index 2 - 1 as the reference).
Then all you have to do is keep the corresponding text & shape layers in the correct order. i.e. Box 1's layer has to be directly below Text 1's layer in the timeline. If there is another layer in between those two layers, it does not work.
How can I modify this expression so it only adjusts the shape's width and not height?
Yeah, this. I quickly found that if you have lowercase text with descenders (or not) it reshapes the box accordingly. But I of course want the same height regardless of which letters I input...
Aaaand I found out myself... Just change the value for "h" to a set value, like so: "h = 100;" for example
was wondering if this can be exported as a MOGRT file?
I haven't done this myself but I believe the answer is yes, you can export this as a MOGRT file. You’ll need to make sure the expression is fully compatible with Essential Graphics. Just add the controls you want to adjust (like text or shape properties) to the Essential Graphics panel, then export it as a MOGRT.