Skip to main content
Known Participant
May 2, 2020
Question

Layer Comp new layers

  • May 2, 2020
  • 3 replies
  • 2181 views

I'm working on a project that has 2 colour outputs, to switch between them will require multiple layers to turn on or off though. Layer comps is the perfect way to switch between these 2 outputs but the problem is the comps seem to be a snapshot of the current document without allowing for more or less layers meaning layer comps are only useful when the project is finished and all i want to do is save out the versions.

There are 2 ways around this that i can think of.

1. Layer comps have a master layer at the top that is referenced, instead of every layer state being saved it only saves the changes, all new layers are assumed on unless specifically switched off.

2. Layer comps have group visability defined seperately from layers, that way if addional layers are added they can be assumed on.

Is there anything out there anyone knows of?

Thanks

It looks like there was a script called Composer which would have been useful to me but its a flash panel so no longer works

This topic has been closed for replies.

3 replies

c.pfaffenbichler
Community Expert
Community Expert
May 4, 2020

You can give this a try to reveal selected Layers in all Layer Comps. 

Edit: Now it’s possible to only add the Layers’ visibility to the selected Layer Comps. 

 

// include selected layers in all or in selected layer comps;
// depending on shift-key;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
activeDocument.suspendHistory ("show selected layers in all comps", "main ()")
};
////// main //////
function main () {
var theLayers = getSelectedLayersIdx();
////// if shift key is pressed get selected comps //////
if(ScriptUI.environment.keyboardState.shiftKey ){
var theComps = getSelectedLayerCompsArray();
////// otherwise get all comps //////
} else {
var theComps = getLayerCompsArray();
};
createLayerComp ("trashthis");
// process layer comps;
for (var m = 0; m < theComps.length; m++) {
applyLayerComp (theComps[m]);
// show layers;
for (var n = 0; n < theLayers.length; n++){
showLayer (theLayers[n])
};
// update;
updateLayerComp ()
};
// reset;
applyLayerComp (activeDocument.layerComps.length);
deleteLayerComp ("trashthis")
};
////////////////////////////////////
////// by paul mr //////
function getSelectedLayersIdx(){ 
    var selectedLayers = new Array; 
    var ref = new ActionReference(); 
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    var desc = executeActionGet(ref); 
    if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){ 
       desc = desc.getList( stringIDToTypeID( 'targetLayers' )); 
        var c = desc.count 
        var selectedLayers = new Array(); 
        for(var i=0;i<c;i++){ 
          try{ 
             activeDocument.backgroundLayer; 
             selectedLayers.push(  desc.getReference( i ).getIndex() ); 
          }catch(e){ 
             selectedLayers.push(  desc.getReference( i ).getIndex()+1 ); 
          } 
        } 
     }else{ 
       var ref = new ActionReference(); 
       ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" )); 
       ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
       try{ 
          activeDocument.backgroundLayer; 
          selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1); 
       }catch(e){ 
          selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))); 
       } 
    } 
    return selectedLayers; 
};
////// apply layer comp //////
function applyLayerComp (theIndex) {
// =======================================================
var desc6 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putIndex( stringIDToTypeID( "compsClass" ), theIndex );
//ref3.putName( stringIDToTypeID( "compsClass" ), theName );
desc6.putReference( stringIDToTypeID( "null" ), ref3 );
executeAction( stringIDToTypeID( "applyComp" ), desc6, DialogModes.NO );
};
////// update layer comp //////
function updateLayerComp () {
// =======================================================
    var desc13 = new ActionDescriptor();
        var ref8 = new ActionReference();
        ref8.putEnumerated( stringIDToTypeID( "compsClass" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
    desc13.putReference( stringIDToTypeID( "null" ), ref8 );
executeAction( stringIDToTypeID( "recapture" ), desc13, DialogModes.NO );
};
////// show layer //////
function showLayer (theIndex) {
// =======================================================
    var desc12 = new ActionDescriptor();
        var list1 = new ActionList();
            var ref7 = new ActionReference();
            /*var idlayer = stringIDToTypeID( "layer" );
            var idordinal = stringIDToTypeID( "ordinal" );
            var idtargetEnum = stringIDToTypeID( "targetEnum" );
            ref7.putEnumerated( idlayer, idordinal, idtargetEnum );*/
            ref7.putIndex( stringIDToTypeID( "layer" ), theIndex );
        list1.putReference( ref7 );
    desc12.putList( stringIDToTypeID( "null" ), list1 );
executeAction( stringIDToTypeID( "show" ), desc12, DialogModes.NO );
};
////// create layer comp //////
function createLayerComp (theName) {
// =======================================================
var desc4 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putClass( stringIDToTypeID( "compsClass" ) );
desc4.putReference( stringIDToTypeID( "null" ), ref2 );
var desc5 = new ActionDescriptor();
desc5.putBoolean( stringIDToTypeID( "useVisibility" ), true );
desc5.putBoolean( stringIDToTypeID( "usePosition" ), true );
desc5.putBoolean( stringIDToTypeID( "useAppearance" ), true );
desc5.putBoolean( stringIDToTypeID( "useChildLayerCompState" ), true );
desc5.putString( stringIDToTypeID( "title" ), theName );
var idcompsClass = stringIDToTypeID( "compsClass" );
desc4.putObject( stringIDToTypeID( "using" ), idcompsClass, desc5 );
executeAction( stringIDToTypeID( "make" ), desc4, DialogModes.NO );
};
////// delete layer comp //////
function deleteLayerComp (theName) {
// =======================================================
var desc10 = new ActionDescriptor();
var ref6 = new ActionReference();
ref6.putName( stringIDToTypeID( "compsClass" ), theName );
desc10.putReference( stringIDToTypeID( "null" ), ref6 );
executeAction( stringIDToTypeID( "delete" ), desc10, DialogModes.NO );
};
////////////////////////////////////
////// get array of selected layer comps’ properties //////
function getSelectedLayerCompsArray () {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var docDesc = executeActionGet(ref);
var compList = docDesc.getList(stringIDToTypeID("compsList"));
var theComps = new Array;
for (var c = 0; c < compList.count; c++) {
var thisOne = compList.getObjectValue(c);
var selected = thisOne.getBoolean(stringIDToTypeID( "selection" ));
if (selected == true) {
theComps.push(thisOne.getInteger(stringIDToTypeID( "itemIndex" )))
}
};
return theComps;
};
////// get array of layer comps’ properties //////
function getLayerCompsArray () {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var docDesc = executeActionGet(ref);
var compList = docDesc.getList(stringIDToTypeID("compsList"));
var theComps = new Array;
for (var c = 0; c < compList.count; c++) {
var thisOne = compList.getObjectValue(c);
theComps.push(thisOne.getInteger(stringIDToTypeID( "itemIndex" )))
//theComps.push([thisOne.getString(stringIDToTypeID( "title" )), thisOne.getInteger(stringIDToTypeID( "itemIndex" ))])
};
return theComps;
};

 

 

Bojan Živković11378569
Community Expert
Community Expert
May 2, 2020

If I can undersand your problem correctly then you are missing feature to update layer comp, take a look at screenshot below. 

Known Participant
May 2, 2020

I have that button and understand I need to press it. But to have to press it every time I add a layer gets very time consuming very fast. Especially if there are lot of layer comps

c.pfaffenbichler
Community Expert
Community Expert
May 2, 2020

Making a (Adjustment) Layer visible in all Layer Comps would likely need a Script. 

 

You can naturally also post a Feature Request over on 

https://feedback.photoshop.com/photoshop_family/

c.pfaffenbichler
Community Expert
Community Expert
May 2, 2020

Could you please post meaningful screenshots with the pertinent Panels (Toolbar, Layers, Layer Comps, Options Bar, …) visible to illustrate what you are talking about? 

 

»comps seem to be a snapshot of the current document without allowing for more or less layers«

I have not noticed problems with fewer Layers; if a Layer is gone it is gone in all Layer Comps. 

 

I suspect one solution to your problem might be, as so often, using Smart Objects. 

Known Participant
May 2, 2020

Smart objects won’t work, they make a working large photoshop file painful if edits are still being made to those layers. You are also working blind if the 2 layers are meant to look like they’re from the same photo.

 

I don’t have access to a computer with photoshop on at the moment so I’ll try to explain.

 

imagine a document with a series of layers or groups.

Layer comp 1 = 5 of those layers are set to be off

layer comp 2 = 5 layers from above layer comp now on. 3 other layers off.

 

put a curve adjustment layer on top of all layers.

now click between Layer comp 1 and Layer comp2. The new curve adjustment layer is off using both layer comps.

this makes adding new adjustments painful as you have to rebuild the layer comps every time a new layer is added.