title: Adobe ExtendScript layer Processing
body: <p>I am trying to create a script for processing layers with inversion. In Photoshop, this is done using ctrl +click on the layer. All the layers in my document are divided into groups. Because of this, an error occurs (photoshop is trying to invert the group). How can I skip groups in a loop or how can I fix it?</p>
  <pre><code>var doc = app.activeDocument;
  var layers =activeDocument.layers;
  
  
  for (var layerIndex = 0; layerIndex&lt;doc.layers.length; layerIndex++) 
  {
      
      var layer = layers [layerIndex];
      doc.activeLayer = layer;
   var idChnl = charIDToTypeID( &quot;Chnl&quot; );
  
              var actionSelect = new ActionReference();
              actionSelect.putProperty( idChnl, charIDToTypeID( &quot;fsel&quot; ) );
  
              var actionTransparent = new ActionReference();
              actionTransparent.putEnumerated( idChnl, idChnl, charIDToTypeID( &quot;Trsp&quot; ) );
  
              var actionDesc = new ActionDescriptor();
              actionDesc.putReference( charIDToTypeID( &quot;null&quot; ), actionSelect );
              actionDesc.putReference( charIDToTypeID( &quot;T   &quot; ), actionTransparent );
  
              executeAction( charIDToTypeID( &quot;setd&quot; ), actionDesc, DialogModes.NO );
              
              
              var invert = doc.selection.invert(actionSelect);
              var clear = doc.selection.clear(invert);
              var des = doc.selection.deselect(clear);
              
            //При попытке выделить группу возникает ошибка, нужно сделать пропуск группы
    }   
  
  
          
  </code></pre>