0

Is it possible to duplicate a layer group that contains multiple smart objects with relationships to each other, so the duplicate group is separated from the original?

I need the duplicate to be editable without changing the original. This can be achieved by the context menu when interacting with a single smart object, but not for a group containing multiple smart objects.

Any ideas?

4

Below is a script that should do what you want.

The script is pretty much identical to the native Duplicate function. The key difference is that Embedded Smart objects within the selection are unlinked from other Embedded Smart objects that sit outside the selection.

This means that if the selected layers are Embedded Smart objects that are direct duplicates of each other, those links won't break.

There is a slight difference in how the layers are named, but I didn't see that as any sort of issue, so I left it like that.


While using a script might feel a bit cumbersome, remember that you can always set a shortcut keys to run scripts:

1. Put the script in the scripts folder.

2. Restart photoshop.

3. Edit > Keyboard shortcuts and menus.

4. In the scrollable area click File and scroll way down to find Scripts> and below that you should find the script name. All that is left is to add the shortcut to it.

enter image description here

The script ( Only tested in PS cc 2014 ):

// https://gist.github.com/joonaspaakko/898394cf2b46ae7b6ad7

#target photoshop

// If there are any documents open, run the code...
// =================================================
if ( app.documents.length > 0 ) {

    // Used later on when the layers are duplicated back to the original document.
    // ===========================================================================
    var docName = app.activeDocument.name;

    // Script listener code - Duplicate active group to a new document.
    // =================================================================
    var idMk = charIDToTypeID( "Mk  " );
        var desc14 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref10 = new ActionReference();
            var idDcmn = charIDToTypeID( "Dcmn" );
            ref10.putClass( idDcmn );
        desc14.putReference( idnull, ref10 );
        var idUsng = charIDToTypeID( "Usng" );
            var ref11 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref11.putEnumerated( idLyr, idOrdn, idTrgt );
        desc14.putReference( idUsng, ref11 );
        var idVrsn = charIDToTypeID( "Vrsn" );
        desc14.putInteger( idVrsn, 5 );
    executeAction( idMk, desc14, DialogModes.NO );


    // Script listener code - Duplicate active group to the prior document.
    // =====================================================================
    var idDplc = charIDToTypeID( "Dplc" );
        var desc16 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref13 = new ActionReference();
            var idLyr = charIDToTypeID( "Lyr " );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref13.putEnumerated( idLyr, idOrdn, idTrgt );
        desc16.putReference( idnull, ref13 );
        var idT = charIDToTypeID( "T   " );
            var ref14 = new ActionReference();
            var idDcmn = charIDToTypeID( "Dcmn" );
            ref14.putName( idDcmn, docName );
        desc16.putReference( idT, ref14 );
        var idVrsn = charIDToTypeID( "Vrsn" );
        desc16.putInteger( idVrsn, 5 );
    executeAction( idDplc, desc16, DialogModes.NO );

    // Closes the new document.
    // =======================================================
    app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );

}
  • Excellent find, thanks for the detailed response. Marking this as the answer as it is now evident the functionality is not built into Photoshop somewhere. – Tom Gantzer Nov 26 '14 at 15:45
  • @TomGantzer Not to toot my own horn, but I wrote the script just for you. Well, actually I did hardly any writing, since I used the Adobe Script listener plugin for most of it. Script listener writes a log file that contains ready to copy&paste javascript blocks for everything you do in photoshop ( Not much different from what you can do with PS Actions, but it can do a lot more, especially when your own code on top of it. ). – Joonas Nov 26 '14 at 15:55
  • Excellent, it's amazing how quickly you solved this one. I'm currently away from the office so I will test this out tomorrow. Thanks a lot! – Tom Gantzer Nov 26 '14 at 16:22
  • @TomGantzer Here's some visuals of it works ( .gif ) – Joonas Nov 26 '14 at 16:51
  • This is great. I should use this, too. – Avetard Nov 27 '14 at 1:10
0

I would drop the layer group into a new, empty document. From there, I would modify the contents inside the smart object at least once - a forward then back nudge will do, save smart object contents, then copy the newly edited layer group back into the main document.

  • Thanks, this seems like the most sensible workaround. I was hoping maybe I'd missed an option somewhere that would give me what I'm looking for :) – Tom Gantzer Nov 26 '14 at 9:50
0

Yes, just make a New Smart Object via Copy of the Layer Group. Then you should be able to modify it without compromise the original group.

0

Copy the group and Convert it to a Smart Object. Then open the Smart Object and drag the group inside back to your original document. Not a very elegant solution, but it gets the job done fast.

  • 1
    Thanks for your tip, I ended up doing it this way until Joonas gave his answer with the script. For all purposes though this is the same solution. Thanks for the help. – Tom Gantzer Nov 27 '14 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.