Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Maintain Gap Between Text Layers, No Matter The Width Of Text

  • Maintain Gap Between Text Layers, No Matter The Width Of Text

    Posted by Andrew Ross
    on January 14, 2022 at 5:25 pm

    Hi guys

    I have a comp with 5 text layers on the X axis.


    I would like these text layers to be positioned 200px apart from each other.


    I’m going to be duplicating this composition numerous times and altering the text using “thisComp.name” but I would like the distance between the layers to remain at 200px no matter how long the word happens to be, whether it’s 3 letters or 20.


    These text layers will be animating along the x-axis from left to right (I’m not sure If this has any bearing on the expression).


    I’ve done some searching on the forums and have found a few expressions that I thought would do the trick, but they always seem to end up with the text overlapping and not keeping the distance between the layers.


    <font face=”inherit”>My knowledge of expressions isn’t that adept to be able to edit them so that’s where I’m probably falling with this one as I imagine it’s a simple task, so apologies if I’m posting something that has already been posted but like </font>I<font face=”inherit”> say, </font>I<font face=”inherit”> can’t get some of the expressions on here to work. </font>


    Thanks in advance
    Andrew

    Filip Vandueren replied 4 years, 2 months ago 4 Members · 4 Replies
  • 4 Replies
  • Kevin Camp

    January 14, 2022 at 7:21 pm

    Something like this should work, add it to the position property and set the ‘target’ to be the layer that you want it to maintain 200px from.

    target = thisComp.layer("LayerToFollow") ;
    rect = target.sourceRectAtTime() ;
    x = target.position[0] + rect.left + rect.width + 200 ;
    [ x, value[1] ]

    The expression assumes that the text layers are left-justified and none are parented.

    If you animate the furthest left text layer, the text layers with that expression will follow it along the x-axis.

  • Andrew Ross

    March 3, 2022 at 10:24 am

    Hi Kevin

    Thanks for getting back with this. It did the job in the end so thank you so much for that 🙂

  • Andy Engelkemier

    March 3, 2022 at 1:05 pm

    Yeah, that parent business what a huge pain in my butt. I realized, after Basically finishing something, that what I had designed would have worked much better with a few child-parent relationships.

    I haven’t come across it yet. Does AE let us do something like: thisLayer == child ? parent info : nonParented value;

    I obviously wouldn’t do that shorthand, but just wanted to get the idea across. I’d Like to create a bunch of code snippets somewhere that I can reuse, and accounting for those things could definitely help, especially if a coworker uses a snippet for something they are working on.

  • Filip Vandueren

    March 4, 2022 at 8:48 am

    Hi Andy, checking that is possible with:

    thisLayer.hasParent

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