Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change layer index by script

  • Change layer index by script

    Posted by Mateo Mazzini on April 12, 2013 at 4:31 am

    I am trying to change the index of a layer with a script, but I can’t find anything in the adobe scripting guide that let me handle the index number.
    I suppose that it should be something like this:
    app.project.activeItem.selectedLayers.index = 1;
    but that doesn’t work.

    Thanks!

    Matz

    Bryan Woods replied 13 years, 3 months ago 3 Members · 4 Replies
  • 4 Replies
  • Bryan Woods

    April 12, 2013 at 4:56 am

    I’m curious about this too actually. Specifically, how to send a layer to the top or bottom of a comp.

  • Dan Ebberts

    April 12, 2013 at 5:29 am

    The index attribute represents the layer’s order in the layer stack and you can’t change that just by setting the index to a new value. You can use the moveToBeginning(), moveToEnd(), moveBefore(), and moveAfter() methods to reorder the layers, which will result in a change to the index attribute.

    Dan

  • Mateo Mazzini

    April 12, 2013 at 6:07 pm

    Thank you!
    This is the solution I end up with!

    Matz

    var activeItem = app.project.activeItem;
    var activeLayers=activeItem.layers;
    for(i=1;i<=activeLayers.length;i++){
    if(app.project.activeItem.layer(i).selected){
    app.project.activeItem.layer(i).moveToBeginning();
    };

    };

    Matz

  • Bryan Woods

    April 13, 2013 at 1:43 am

    Looks like CC botched your code. Should probably be this:


    var activeItem = app.project.activeItem;
    var activeLayers=activeItem.layers;
    for(i=1;i<=activeLayers.length;i++){
    if(app.project.activeItem.layer(i).selected){
    app.project.activeItem.layer(i).moveToBeginning();
    };

    };

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