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

Layer Sets (groups)

$
0
0

Hi fellas. It's been a while!

I tend not to use groups (layer sets) myself, but other people do. I've got several scripts that loop over all layers in a psd and then peform various tasks.

Of course they fall over if layersets are involved; so I need to change that.

To test this out I wrote a script and made a simple psd; New document (any size), background, one layer (called "layer 1") and another layer ("layer 2") which is in a layer set ("a_group")

I've got a basic script here that loops through all layers (or so I thought)

 

<code>

var srcDoc = app.activeDocument;

var numOfLayers = srcDoc.layers.length;

 

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

 

 

{    var layerName = srcDoc.layers[i].name;

    // check for groups

    if (srcDoc.layers[i].typename == "LayerSet")

    {

    alert (layerName + " is a group")

    }

    else

    {

    alert (layerName + " is not in a group")

    }

</code>

 

The alert calls all layer names as it goes up the stack. It however misses out layer 2 (which is in a group) So what am I missing out?

Cheers


Viewing all articles
Browse latest Browse all 12244

Trending Articles



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