Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to keep two text layers centered in comp and maintain space between

  • Expression to keep two text layers centered in comp and maintain space between

    Posted by Riccardo Sinti on June 16, 2014 at 6:40 pm

    I’m creating phone Number localizations for 150 spots.
    I’m testing running the ‘compsFromSpreadsheet4″ script to replace the phone number for all these different locals.
    So far great, I can get the script to replace the number but the problem is some digits throw off the horizontal size of the phone number.
    The phone number is paired with a text layer that has a URL that will remain the same.
    So the layout is:
    website.com 1-800-123-4567
    the two text layers are centered in the comp.
    Is there an expression that can maintain the space between the two text layers and repo them so they are centered in the comp, so that when I run the script the positions of these layers will automatically update and I don’t have to go into 150 comps to center everything?
    Thanks in advance!

    Kevin Camp replied 11 years, 11 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 16, 2014 at 7:03 pm

    I’d recommend you do this with a script. Either modify your text-replacement script, or create another one that you run afterwards to tidy up the positions of the text layers. The reason for using a script is that scripts have access to the actual dimensions of the text via sourceRectAtTime(), and expressions don’t.

    Dan

  • Riccardo Sinti

    June 16, 2014 at 7:26 pm

    Thanks for the answer, I guess it’s manual work for me because I wouldn’t know how to script that.
    So does that mean that there can’t be an expression that would reposition a text layer to maintain it’s right edge as the text is updated?

  • Dan Ebberts

    June 16, 2014 at 7:46 pm

    Search this forum for the sampleImage hack. You can use it, for example, to find the left edge of a text layer’s text by starting at column x=0 and examining the layer in one-pixel columns from left to right, until you find a column with alpha greater than zero. It works, but it’s slow.

    Seriously though, if performance is an issue, scripting is the way to do this.

    Dan

  • Kevin Camp

    June 16, 2014 at 11:07 pm

    i’d try to put both the url and phone# in the same text layer with a few spaces in between.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy