Highlighted

Expression to centre align text to shape

New Here ,
Oct 20, 2020

Copy link to clipboard

Copied

I have an answer box to produce into a template. I'd like the user to type the answers into the boxes but the answers may vary from one line or two. I'm using paragraph text not point text so it doesn't type outside the box.

 

Problem: So if space for two lines but an answer only reaches one line the text is then aligned to the top not the centre, it looks silly but makes sense since the paragraph text allows for two lines. Obviously if I allow for one line I won't be able to include full answers.

 

I'm looking for an expression and because I'm not THAT advanced, the expression method. I assume I'll need to pick whip to the shape layer in the expression? but I don't want the shape layer/text box to auto-scale! just auto-align. I also don't want the font size to autoscale either. Not entirley sure what to put where - where to type the expression on what layer. I assumed it would be in the anchor point or position of the text then pickwhip but the text box won't be moving so I'm really unsure. I found some websites and forums that almost answers me but still lost.

https://creativecow.net/forums/thread/center-anchorpoint-no-matter-the-content-of-text-f/
https://www.reddit.com/r/AfterEffects/comments/54bhsh/scale_text_to_fit_inside_box_expression/

Last one almost worked but it didn't quite consider the shape layer even when I changed thiscomp to this layer and used pickwhip.
// calcuate the center of thisComp.layer("A");

[thisLayer.width/3.5, thisLayer.height/2]

Never done expressions before so that was the best I could attempt to work out

Thanks in advance

Never mind, I found it. For those who are also looking:

1. Put the anchor point in the middle of the text box

2. alt/option click anchor point to open expression editor and type in 

// [CENTER, CENTER]

l = thisLayer.sourceRectAtTime();

[l.left + l.width/2, l.top + l.height/2];

3. Parent the text layer to the shape layer

4. Align everything up if not already (to selection not comp)

TOPICS
Expressions, How to

Views

31

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Expression to centre align text to shape

New Here ,
Oct 20, 2020

Copy link to clipboard

Copied

I have an answer box to produce into a template. I'd like the user to type the answers into the boxes but the answers may vary from one line or two. I'm using paragraph text not point text so it doesn't type outside the box.

 

Problem: So if space for two lines but an answer only reaches one line the text is then aligned to the top not the centre, it looks silly but makes sense since the paragraph text allows for two lines. Obviously if I allow for one line I won't be able to include full answers.

 

I'm looking for an expression and because I'm not THAT advanced, the expression method. I assume I'll need to pick whip to the shape layer in the expression? but I don't want the shape layer/text box to auto-scale! just auto-align. I also don't want the font size to autoscale either. Not entirley sure what to put where - where to type the expression on what layer. I assumed it would be in the anchor point or position of the text then pickwhip but the text box won't be moving so I'm really unsure. I found some websites and forums that almost answers me but still lost.

https://creativecow.net/forums/thread/center-anchorpoint-no-matter-the-content-of-text-f/
https://www.reddit.com/r/AfterEffects/comments/54bhsh/scale_text_to_fit_inside_box_expression/

Last one almost worked but it didn't quite consider the shape layer even when I changed thiscomp to this layer and used pickwhip.
// calcuate the center of thisComp.layer("A");

[thisLayer.width/3.5, thisLayer.height/2]

Never done expressions before so that was the best I could attempt to work out

Thanks in advance

Never mind, I found it. For those who are also looking:

1. Put the anchor point in the middle of the text box

2. alt/option click anchor point to open expression editor and type in 

// [CENTER, CENTER]

l = thisLayer.sourceRectAtTime();

[l.left + l.width/2, l.top + l.height/2];

3. Parent the text layer to the shape layer

4. Align everything up if not already (to selection not comp)

TOPICS
Expressions, How to

Views

32

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 20, 2020 0
New Here ,
Oct 20, 2020

Copy link to clipboard

Copied

Never mind, I found it. For those who are also looking:

1. Put the anchor point in the middle of the text box

2. alt/option click anchor point to open expression editor and type in 

// [CENTER, CENTER]

l = thisLayer.sourceRectAtTime();

[l.left + l.width/2, l.top + l.height/2];

3. Parent the text layer to the shape layer

4. Align everything up if not already (to selection not comp)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 20, 2020 0