Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change layer order with expressions

  • Change layer order with expressions

    Posted by Mattmariska on February 15, 2007 at 4:07 am

    Hello! I’m new to posting to these forums, but I’ve been reading them for help countless times over the past years.

    I’m just a beginner with AE Expressions, and I was wondering if the following is possible:

    I would like to change the order (or perceived order) of layers in my composition, based on their Y axis. In this composition, the lower a layer is vertically, the closer it should be to the camera. Therefore, anything lower vertically should overlap anything else higher vertically. Is this possible?

    I hope I’m explaining myself well enough. Thank you for taking the time to give me a hand with this.

    -Matt

    Mark Mitchell replied 7 years, 2 months ago 4 Members · 4 Replies
  • 4 Replies
  • Colin Braley

    February 15, 2007 at 7:24 am

    Well you can’t make the layers become stacked in a different order via expressions, however scripting could sort the layers based on the y position at frame zero, or something like that. However, you could change the z-position of layers based on y position. You could create an expression to do something like place the layer with the largest y value at z = 0, the layer with the second largest y value at z = -100, the layer with the third largest y value at z = -200 etc. Just clarify what you are looking for a bit more and Im sure someone will be able to help you out.
    ~Colin

  • Dan Ebberts

    February 15, 2007 at 2:30 pm

    Yeah, I’d make them all 3D and use an expression like this to sort them in Z space:

    below = 0;
    for (i = 1; i <= thisComp.numLayers; i++){ if (i == index) continue; if (thisComp.layer(i).position[1] < value[1]) below--; } [value[0],value[1],below] Dan

  • Mattmariska

    February 15, 2007 at 6:37 pm

    Thanks! I’ll give this a try, and see if it works out.

    Thanks for taking the time to look this over.

  • Mark Mitchell

    February 22, 2019 at 2:31 pm

    Hi Dan I have 8 layers where I need to have only one layer at a time above all the others – like the apple dock. I am not familiar with expressions and hope you can explain which parameters I need to change to hopefully have this expression work for me.

    Thanks.
    Mark

    Regards

    Mark

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