ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change layer index by script

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mateo Mazzini
Change layer index by script
on Apr 12, 2013 at 4:31:05 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


Return to posts index

Bryan Woods
Re: Change layer index by script
on Apr 12, 2013 at 4:56:44 am

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


Return to posts index


Dan Ebberts
Re: Change layer index by script
on Apr 12, 2013 at 5:29:30 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



Return to posts index


Mateo Mazzini
Re: Change layer index by script
on Apr 12, 2013 at 6:07:16 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&lt;=activeLayers.length;i++){
if(app.project.activeItem.layer(i).selected){
app.project.activeItem.layer(i).moveToBeginning();
};

};


Matz


Return to posts index

Bryan Woods
Re: Change layer index by script
on Apr 13, 2013 at 1:43:06 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();
};

};


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]