8 Replies Latest reply: Mar 11, 2011 5:02 AM by c.pfaffenbichler RSS

    Cut/paste whole layers?

    per.lindgren Community Member

      This is my number one feature request, because I can't seem to find this anywhere in Photoshop. What I would like is to be able to cut a layer or a layer group, which means it disappears in the layer palett, then I want to select another layerfolder, for example, and paste the layer back. This would make it really easy to place objects and layers in the correct stacking order, without having to drag-drop layers in the palett.

       

      I do this all the time in Adobe Fireworks, but it doesn't work in Photoshop. Or does anyone have a smart workaround for this?

        • 1. Re: Cut/paste whole layers?
          Mike Gondek2 Community Member

          You can not cut/copy/paste layers with their layer names in photoshop, and don't see an action being able helping either. Best help you may get for working with documents with lots of layers are these keyboard commands.

           

           

           

          Group layers

          Control + G

          Command + G

          Ungroup layers

          Control + Shift + G

          Command-Shift + G

          Create/release clipping mask

          Control + Alt + G

          Command-Option + G

          Select all layers

          Control + Alt + A

          Command + Option + A

          Merge visible layers

          Control + Shift + E

          Command + Shift + E

          Create new empty layer with dialog box

          Alt-click New Layer button

          Option-click New Layer button

          Create new layer below target layer

          Control-click New Layer button

          Command-click New Layer button

          Select top layer

          Alt + . (period)

          Option + . (period)

          Select bottom layer

          Alt + , (comma)

          Option + , (comma)

          Add to layer selection in Layers panel

          Shift + Alt + [ or ]

          Shift + Option + [ or ]

          Select next layer down/up

          Alt + [ or ]

          Option + [ or ]

          Move target layer down/up

          Control + [ or ]

          Command + [ or ]

          Merge a copy of all visible layers into target layer

          Control + Shift + Alt + E

          Command + Shift + Option + E

          Merge layers

          Highlight layers you want to merge, then Control + E

          Highlight the layers you want to merge, then Command + E

          Move layer to bottom or top

          Control + Shift + [ or ]

          Command + Shift + [ or ]

          Copy current layer to layer below

          Alt + Merge Down command from the Panel pop‑up menu

          Option + Merge Down command from the Panel pop‑up menu

          • 2. Re: Cut/paste whole layers?
            per.lindgren Community Member

            Thanks, but I can't seem to find any function or keyboard command to cut/copy/paste a layer?? I know how to move layers and change selected layer, but how can I cut and paste a layer? How would I create this action?

            • 3. Re: Cut/paste whole layers?
              c.pfaffenbichler Community Member
              how can I cut and paste a layer?

              Far as I know you can’t.

              And I think it’s fine this way, because of interference with selections, pixel content, paths etc. and the amount of data potentially involved.

              And anyway, dragging in the Layers Panel does not seem that much of a hassle to me.

               

              How would I create this action?

              I suppose one could achieve something approximating such a behaviour with Scripts (and either assign them shortcuts or Configurator Panel buttons).

              One Script could duplicate the selected Layer Group to a new document and delete it in the old and the second Script one could re-insert the items above/into a selected Layer/Layer Group.

               

              Anyway, you could also post in the Feature Request Forum.

              • 4. Re: Cut/paste whole layers?
                Reynolds (Mark) Community Member

                Photoshop has many better ways of copying layers. For example you can Alt drag layers, or selected groups of layers in the layers Panel. This will duplicate them very quickly to wherever you want in the Panel. The shortcut command J will also copy a layer. Also, with Move tool active, you can hold Alt and drag layers from within the document area to duplicate them interactively.

                 

                Photoshops clipboard cannot contain a whole layer or group of layers. So you can't Copy and Paste them. If your layer is in Normal blend mode and has no transparency then you can select all (Command A) and paste in into a different place. This can be Actioned.

                • 5. Re: Cut/paste whole layers?
                  c.pfaffenbichler Community Member

                  I’ve been giving the Scripting some thought … one could also create a Script that offers a dialog with the list of all layers and layer groups (or only layer groups if one should prefer that) and one can select one of those and the originally selected layer will be moved into the group or in front of the layer.

                  per.lindgren, would that be any use to you?

                  • 6. Re: Cut/paste whole layers?
                    per.lindgren Community Member

                    c.pfaffenbichler >> Yes, that would probably be VERY useful! How can I create a script like that??

                    • 7. Re: Cut/paste whole layers?
                      c.pfaffenbichler Community Member

                      Unless you have experience with JavaScipt and the Photoshop-Document Object Model that may be difficult for you.

                      But you can ask if somebody has such a Script already or can help you in the Photoshop Scripting Forum:

                      http://forums.adobe.com/community/photoshop/photoshop_scripting

                      • 8. Re: Cut/paste whole layers?
                        c.pfaffenbichler Community Member

                        If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CS4 or /Applications/Utilities/Adobe Utilities-CS5/ExtendScript Toolkit CS5) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.

                        After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action, (in CS4 and CS5) be used in a Configurator-Panel or started from ExtendScript Toolkit directly.

                         

                        (Edited)

                        // moves selected layers to a new destination within the document, in front of artlayers into layersets;
                        // 2011, use at your own risk; 
                        #target photoshop
                        if (app.documents.length > 0) {
                        main()
                        };
                        ////////////////////////////////////
                        ////////////////////////////////////
                        ////////////////////////////////////
                        ////// function //////
                        function main () {
                        app.togglePalettes();
                        // get properties;
                        var myDocument = app.activeDocument;
                        var theLayer = myDocument.activeLayer;
                        // get the layers;
                        var theLayers = collectLayers(myDocument);
                        ////////////////////////////////////
                        // create the dialog;
                        var dlg = new Window('dialog', "move layer into/in front of", [500,300,930,935]);
                        //create list for layer-selection;
                        dlg.layerRange = dlg.add('panel', [21,20,410,585], "Select the layer");
                        dlg.layerRange.layersList = dlg.layerRange.add('listbox', [11,20,374,545], '', {multiselect: false});
                        for (var q = 0; q < theLayers.length; q++) {
                             var aLayer = theLayers[q];
                             var theName = aLayer.name;
                             while (aLayer.parent != myDocument) {
                                  theName = "   " + theName;
                                  aLayer = aLayer.parent     
                                  }; 
                             dlg.layerRange.layersList.add ("item", theName);
                             dlg.layerRange.layersList.items[q].selected = true
                             };
                        dlg.layerRange.layersList.onDoubleClick = function () {this.parent.parent.close(1)};
                        dlg.layerRange.layersList.active = true;
                        // ok- and cancel-buttons;
                        dlg.buildBtn = dlg.add('button', [220,595,410,615], 'OK', {name:'ok'});
                        dlg.cancelBtn = dlg.add('button', [21,595,210,615], 'Cancel', {name:'cancel'});
                        dlg.center();
                        ////////////////////////////////////
                        ////// based on a getLayerId and getLayerItemIndexByLayerID by mike hale //////
                        var myReturn = dlg.show ();
                        // in case of OK;
                        if (myReturn == 1) {
                        // get index number;
                             for (var m = 0; m < dlg.layerRange.layersList.items.length; m++) {
                                  if (dlg.layerRange.layersList.items[m].selected == true) {
                                       theNumber = m
                                       }
                                  };
                        ////////////////////////////////////
                        // get the layer;
                             var theTargetLayer = theLayers[theNumber];
                        // to throw history in order to be able to get back to the original layer selection;
                             myDocument.quickMaskMode = true;
                             myDocument.quickMaskMode = false;
                             myDocument.quickMaskMode = true;
                        // get the index;
                             var theTargetIndex = getLayerItemIndex(theTargetLayer);
                        // return;
                             app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 1];
                        // move the layers;
                             try {
                                  if (theTargetLayer.typename == "LayerSet") {
                                       moveLayersInFrontOf (theTargetIndex - 1)
                                       }
                                  else {
                                       moveLayersInFrontOf (theTargetIndex)
                                       };
                                  }
                             catch (e) {alert ("layers could be moved to the intended postition")};
                             };
                        app.togglePalettes();
                        };
                        ////// function collect all layers and their visibilites //////
                        function collectLayers (theParent) {
                             if (!allLayers) {
                                  var allLayers = new Array}
                             else {};
                             for (var m = 0; m < theParent.layers.length; m++) {
                                  var theLayer = theParent.layers[m];
                        // apply the function to layersets;
                                  if (theLayer.typename == "ArtLayer") {
                                       allLayers.push(theLayer)
                                       }
                                  else {
                        // this line includes the layer groups;
                                       allLayers.push(theLayer);
                                       allLayers = allLayers.concat(collectLayers (theLayer));
                                       }
                                  };
                             return allLayers
                             };
                        ////// move layer in front of layer by index //////
                        function moveLayersInFrontOf (index) {
                        // =======================================================
                        var idmove = charIDToTypeID( "move" );
                            var desc17 = new ActionDescriptor();
                            var idnull = charIDToTypeID( "null" );
                                var ref17 = new ActionReference();
                                var idLyr = charIDToTypeID( "Lyr " );
                                var idOrdn = charIDToTypeID( "Ordn" );
                                var idTrgt = charIDToTypeID( "Trgt" );
                                ref17.putEnumerated( idLyr, idOrdn, idTrgt );
                            desc17.putReference( idnull, ref17 );
                            var idT = charIDToTypeID( "T   " );
                                var ref18 = new ActionReference();
                                var idLyr = charIDToTypeID( "Lyr " );
                                ref18.putIndex( idLyr, index );
                        //        ref18.putIndex( idLyr, 9 );
                            desc17.putReference( idT, ref18 );
                            var idAdjs = charIDToTypeID( "Adjs" );
                            desc17.putBoolean( idAdjs, false );
                            var idVrsn = charIDToTypeID( "Vrsn" );
                            desc17.putInteger( idVrsn, 5 );
                        executeAction( idmove, desc17, DialogModes.NO );
                        };
                        ////// based on a getLayerId and getLayerItemIndexByLayerID by mike hale //////
                        function getLayerItemIndex(layer) {
                        app.activeDocument.quickMaskMode = true;
                        app.activeDocument.quickMaskMode = false;
                        app.activeDocument.activeLayer = layer;
                        //Assumes activeDocument and activeLayer
                            var ref = new ActionReference(); 
                            ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt")); 
                            d = executeActionGet(ref); 
                        var id = d.getInteger(charIDToTypeID('LyrI'));
                        // get index;
                            var ref = new ActionReference(); 
                            ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" )); 
                            ref.putIdentifier( charIDToTypeID( "Lyr " ), id ); 
                        try{var itemIndex = executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))}
                        catch(e){var itemIndex = true};
                        //
                        app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
                        app.activeDocument.quickMaskMode = false;
                        return itemIndex
                        };