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

Center align (horizontally) two text layers to comp

Community Beginner ,
Oct 25, 2021 Oct 25, 2021

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
924
Translate
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.

 

Translate
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.

 

Translate
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

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

Translate
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
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!

Translate
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