Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

Help a noob with a script.

$
0
0

I have a number of layers (0,1, 2,..., N), that I need to be copied in a certain way.


1 step) Copy Layers with index: N, N-1, ..., 2, 1, 0.

2 step) Copy Layers with index: N-1, N-2, ..., 2, 1, 0.

3 step) Copy Layers with index: N-2, N-3, ..., 2, 1, 0.

---------------------------------------------------------------------------

N - 1 step) Copy Layers with index:  2, 1, 0.

N step) Copy Layers with index:  1, 0.

Last step) Copy Layer with index:  0.

   

For example i have 4 layers (0,1,2,3)

  1. Copy Layers with index:  3, 2, 1, 0.
  2. Copy Layers with index:  2, 1, 0.
  3. Copy Layers with index:  1, 0.
  4. Copy Layers with index:  0.

So in the end there must be: 1 copy of № 3, 2 copies of № 2, 3 copies of № 1, 4 copies of № 0


Script Code:


var length;

length = app.activeDocument.artLayers.length;

for( var i = length-1; i >= 0; i--)

    {

          for (var y=i; y >= 0; y--)

              {

                    app.activeDocument.layers[y].duplicate();

              }

    }


But it works wrong somehow.

For 4 layers i got in the end: 1 copy of № 3, 1 copy of № 2, 2 copies of № 1, and 6copies of № 0





Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>