4 Replies Latest reply on Aug 15, 2013 10:29 AM by mauritsbrock

    Selecting multiple layers and merge

    mauritsbrock Level 1

      is it possible to select multiple layers (with layermask) and merge them?

       

      tell application "Adobe Photoshop CS6"

          tell current document

              set current layer to every layer of layer set "bloem 1-9" of layer set "Bloem"

              tell current layer

                  merge

              end tell

          end tell

      end tell

        • 1. Re: Selecting multiple layers and merge
          Michael L Hale Level 5

          Not sure how to do this in Applescript but I understand that Applescript has a do Javascript command so this might help.

           

          With javascript you don't have to select all the layers in a set. You just select the layerSet and merge.

           

          app.activeDocument.activeLayer.merge(),

          • 2. Re: Selecting multiple layers and merge
            mauritsbrock Level 1

            Thanks Michael,

            it works great but the problem is that i lose the folder of the layers. Is it posible to merge the layers within the folder and keeping the folder?

             

            Maurits

            • 3. Re: Selecting multiple layers and merge
              Michael L Hale Level 5

              Yes, for that you have to select the layers that are in the set. Here is one way using javascript

               

              function selectLayerBelow( add ){
                  var desc = new ActionDescriptor();
                      var ref = new ActionReference();
                      ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Bckw" ) );
                  desc.putReference( charIDToTypeID( "null" ), ref );
                  if(add!=undefined && add = true )desc.putEnumerated( stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelectionContinuous') );
                  desc.putBoolean( charIDToTypeID( "MkVs" ), false );
                  executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
              };
              // assumes a layerSet the the activeLayer and doesn't work correctly if there are nested layerSets
              var numberOfLayersInSet = app.activeDocument.activeLayer.layers.length;
              selectLayerBelow();
              for(var layerIndex = 1;layerIndex<numberOfLayersInSet;layerIndex++){
                  selectLayerBelow( true );
              }
              app.activeDocument.activeLayer.merge();
              
              • 4. Re: Selecting multiple layers and merge
                mauritsbrock Level 1

                Thank you Michael!