Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Vertical distribution depending on which layers are visible.

  • Vertical distribution depending on which layers are visible.

    Posted by Chris Meadmore on March 29, 2024 at 8:24 pm

    I’m creating a schedule and have 7 comps, one for each day, distributed vertically. Within each comp is a text layer, if the text layer contains no characters it turns the parent comp opacity to 0.

    How can I set those 7 parent comps up so that as their opacities change to 0 the remaining comps reposition to maintain an even distribution?I

    ‘m assuming some kind of array unique to each layer – if (x) amount of layer opacities set to 0 – set Y position to…?

    This is set to be driven by essential graphics so it’s important than any layer can be turned off and the rest react accordingly.

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

    March 29, 2024 at 8:39 pm

    This is a simple example with lots of assumptions. It assumes that the layers participating are at the top of the layer stack (layers 1 thru n). It expression counts the number of layers above its host layer that have opacity = 0. For each of those it finds, it move upwards a distance equal to its own height.:

    n = 0;
    for (i = 1; i < index; i++){
    if (thisComp.layer(i).opacity == 0) n++;
    }
    value - [0,n*height]
  • Chris Meadmore

    March 29, 2024 at 9:31 pm

    Thanks Dan! That’s definitely in the right direction, it’s doing exactly what I need in terms of repositioning the comps but I need them all to stay centrally aligned in order to wrap the shape layer around them all.

    I can do the shape layer via sourceRectAtTime but would the central alignment be via a separate Nul or baked into the position expression?

    Images attached for more clarity.

  • Dan Ebberts

    March 29, 2024 at 10:45 pm

    I think the expression would need to know the gap between layers. Then something like this would work (it assumes all layers in the comp are participating):

    gap = 50
    n1 = 0;
    for (i = 1; i < index; i++){
    if (thisComp.layer(i).opacity == 0) n1++;
    }
    n2 = 0;
    for (i = index+1; i <= thisComp.numLayers; i++){
    if (thisComp.layer(i).opacity == 0) n2++;
    }
    value - [0,(n1-n2)*(height +gap)/2]

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