It is just a little variation on the Reverse Layer Order, but with an extra selection option. Now it's possible to select these layers which have to be reversely ordered.
The difficult part was to find out that layers in a selection appear in an order, which depend on the order they have been selected. If we do not sort the index from these layers, the reordening proces could easily give a mess.
Originally I wrote:
Code: Select all
...
for(j = 1; j <= length; j++) // collect in array SNA all layers which should be reordered
{
SNA[j]=myComp.selectedLayers[j-1].index;
}
for(j = 1; j < length; j++) // sort elements ascending; SNA[1] holds lowest value
{
pL=length;
do
{
if (SNA[j]>SNA[pL]) // swap elements to get lowest of this pair first
{
w=SNA[pL];
SNA[pL]=SNA[j];
SNA[j]=w;
}
} while (--pL > j);
}
...
Code: Select all
...
function comparefn(x, y) {return x - y;}
...
function reverseSelectedLayerOrder(myComp){
var comp_layers = myComp.layers;
var length = myComp.selectedLayers.length;
var SNA = new Array();
var pL;
var w;
if (length > 1) // only process 2 or more selected layers
{
for(j = 0; j < length; j++) // collect in array SNA all layers which should be reordered
{
SNA[j]=myComp.selectedLayers[j].index;
}
SNA=SNA.sort(comparefn); // sort elements ascending; SNA[0] holds lowest value
...
http://www.nijdam.de/aescripts/ReverseS ... rOrder.zip