• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Expression to centre align text to shape

Community Beginner ,
Oct 20, 2020 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

TOPICS
Expressions , How to

Views

13.3K

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
community guidelines

correct answers 1 Correct answer

Community Beginner , Oct 20, 2020 Oct 20, 2020

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)

Votes

Translate

Translate
Community Beginner ,
Oct 20, 2020 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)

Votes

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
community guidelines
New Here ,
Feb 01, 2022 Feb 01, 2022

Copy link to clipboard

Copied

thank you so much ^^

Votes

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
community guidelines
Community Beginner ,
Sep 15, 2022 Sep 15, 2022

Copy link to clipboard

Copied

LATEST

Exactly what I needed, thank you!!!!!

Votes

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
community guidelines