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

Center align (horizontally) two text layers to comp

Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

Hey all,

Looking for help on aligning two seperate text layers, both of which will be dynamic based on mograph input, to my comp's center.  In others words, I want to the two layers to be centered no matter what is typed in fields.  Any suggestions on building an expresion or script that could help me solve this?

 

lenzi315_0-1635179714694.png

 

TOPICS
Expressions , How to

Views

699

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 25, 2021 Oct 25, 2021

I figured it out.  If you're interested.

 

I centered the first text layer

Used sourceRectatTime to determine its width,

Offset the x position of the second text layer by one half of the first text layer's width

Parented both layers to a null object, centered in the comp

Offset the x position of the null by minus half the width of the second text layer (again using sourceRectatTime)

 

That seems to have solved my problem.

 

Votes

Translate

Translate
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

I figured it out.  If you're interested.

 

I centered the first text layer

Used sourceRectatTime to determine its width,

Offset the x position of the second text layer by one half of the first text layer's width

Parented both layers to a null object, centered in the comp

Offset the x position of the null by minus half the width of the second text layer (again using sourceRectatTime)

 

That seems to have solved my problem.

 

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
Adobe Employee ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

Glad to hear that you worked it out. Thanks for updating the thread.

Feel free to reach out if there are any other questions.

 

Thanks,

Nishu

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 ,
Nov 08, 2023 Nov 08, 2023

Copy link to clipboard

Copied

LATEST

Hey - I'm trying to build a similar setup, but I'm new to expressions. Would you be able to explain a little further or perhaps share the code you used? Please and 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