Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Evenly distributing editable text layers horizontally

  • Evenly distributing editable text layers horizontally

    Posted by Jan Werthwein on August 14, 2024 at 6:53 pm

    Hi there, I’ve been tasked with making an editable progress bar MOGRT.

    It will basically be 4 or 5 topics across the length of the screen with a line divider in between, image attached. I was using Pins and Boxes to help with the dividing line spacing, and parenting each text layer to the previous text layers pins to keep them spaced evenly.

    For example:

    | INTRO BUILD RESILIENCE | KEY INSIGHTS | PANEL DISCUSSION | METHODOLOGY |

    I can’t seem to figure out how to keep the layers evenly spaced across the screen if the text is changed. For example if the first topic “INTRO BUILD RESILIENCE” were to be changed to “INTRO.”

    Ideally in this situation I’d like all the layers to space between themselves automatically and keep the same distance from the left and right side of the bar.

    Any thoughts on how to do this?

    Dan Ebberts replied 1 year, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 14, 2024 at 7:32 pm

    I’m making a lot of assumptions here, but it might be helpful. I’m only considering the text layers themselves, I’m assuming there are 4 of them and that they are layers 1 thru 4 in the layer stack. I’m assuming the the margins at the edges of the comp will be half the spacing between the text layers. With that in mind, I think this position expression will space your text layers in the x direction:

    n = 4; // number of text layers participating
    // get total text width for all layers
    w = 0;
    for (i = 1; i <= n; i++){
    w += thisComp.layer(i).sourceRectAtTime(time).width;
    }
    // calcuate extra space
    s = thisComp.width - w;
    gap = s/n; // gap between text layers
    margin = gap/2
    // calculate where my left edge should be
    myLeftEdge = margin;
    for (i = 1; i < index; i++){
    myLeftEdge += thisComp.layer(i).sourceRectAtTime(time).width + gap;
    }
    // move this layer into position
    [myLeftEdge - sourceRectAtTime(time).left, value[1]]
  • Jan Werthwein

    August 14, 2024 at 7:36 pm

    I’ll give this a shot! So do I apply this expression to the source text property of all 4 layers?

  • Dan Ebberts

    August 14, 2024 at 7:39 pm

    No, it’s a position expression.

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