• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Way to turn on the next hidden layer to automate comps

Community Beginner ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

Hi all,

I need to make 100s of layers comps across multiple files which involve making a comp, turning one layer off then turning the next layer on, making a new comp.

 

I've been able to make one where all the layers are just on and then I make a comp, turn the current layer off, make a new comp, etc but I now have layers with transparency so I have to turn each one on individually for each comp. Cycling through layers and turning visibility on doesn't seem to be a function as cycling only registers layers that are already on.

 

Maybe I'm missing something or there is a better way to do this? 

 

My current action is to have all the layers on, select the top on then hit the action:

- make layer comp

- turn off current layer

- select backward layer

then these 3 things are repeated a number of times in the action.

 

Any ideas?

 

Thanks!

TOPICS
Actions and scripting , macOS

Views

221

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

One thought is have you tried using groups when building to simplify the structure?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

All the background elements and other bits and pieces are in their relevant groups and then all the images/layers that need turning on and off are in their own group too. 

 

Do you mean to make each layer comp its own group? 

The file uses all the same elements for every layer comp, except the image that needs to change so duplicating everything else 50+ times would make the file crazy large 😕

 

So I actually have everything except the images as 3 or 4 layer comps which will form parent pages in indesign (the difference being one has 3 lines of colour on it, another has 3 different lines of colour, the others have 1 or 2 coloured lines). Then I have the group of images which I've layer comped on their own one at a time without anything else. Those are being added to my data merge But I had to go through and manually make layer comp, turn off layer, turn on next layer, make layer comp for all 50+ images in the file. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

I would say make the modified items in one group all named the same thing. That way you could script it to show/hide specifically named groups. Hide group X save comp. Hide group Y save comp, etc. etc.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

quote

...But I had to go through and manually make layer comp, turn off layer, turn on next layer, make layer comp for all 50+ images in the file. 


By @Flo98A1

 

This could be scripted. I'm guessing that you need something more than this.

 

Could you post a screenshot of the layers panel? Perhaps mark/annotate which layers need to be cycled on/off and comped.

 

If it would be workable to select multiple layers in the layers panel to be cycled on/off and create a comp, that could be scripted. What do you think?

 

I'm assuming that you have a bunch of visible layer groups that are the "base image" that don't need their visibility changed, then above them you have a bunch of layers or layer groups that you need to cycle through and make visible one by one, creating a layer comp each time.

 

An action could semi-automate these steps, or do this for a fixed/known quantity of layers, however, if the layer count is variable then a script would be better.

 

EDIT: Without using layer comps, a script such as in the following link can create the layer combinations:

 

https://github.com/mechanicious/photoshopCompositionComposer

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

Thanks Kevin for the idea and thanks Stephen for the scripts! I have no idea how to create a script myself so these examples are great. I'm just moving onto the next file now so will give them a go. The reasoning behind using the layer comps is that I then need to export the layer comps as file to out into indesign and data merge all the text onto them, but again there may be a way of doing that without the layer comps. 

The screenshots attached are the grouped layers, then expanded colour strips which I made the parent pages for indesign from and then the red folder is the images that I turned everything else off for and turned those on one at a time to make a layer comp so the indesign file and data merge would have 1 image per page on it with transparency through to the backgrounds on the parent pages. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

I'm wondering if you could incorporate the Make Frames From Layers command in your process. Make Frames From Layers is a feature that you would use to make frames for an animated GIF that does the following for you automatically when you start with only the bottom layer visible:

  1. Makes a frame in the Timeline for the current visible layer
  2. Turns the visibility for the current layer off
  3. Makes the next layer above the current layer visible
  4. Repeats steps 1-3 until it has gone through all of the layers

 

The resulting frames in the Timeline are similar to Layer Comps in that they are made up of visible layers. You could use those visible layers to create your Layer Comps.

 

To set it up, you would need to do the following:

  1. Show the Timeline (Window > Timeline)
  2. Click the Create Frame Animation button in the Timeline panel (if it's not showing, then use the dropdown menu)
  3. Go to the Timeline panel menu (the hamburger menu in the upper right of the Timeline)
  4. Hide all the layers except for the bottom one
  5. Select Make Frames From Layers

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

Ah this sounds promising too. Can the frames then be exported as separate files to go one each to a page in an indesign doc? Will give it a try, thanks!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

You would need to make the layer comps from the frames, and then you could use File > Export > Layer Comps to Files.

 

But as I reread your question, it sounded like the layer comps may be made of single layers. If that's the case, then the simplest way to export them individually would be to do the following:

  1. Select all the layers in the Layers panel
  2. Right-click in the black space to the right of the layer names and select Export As... (or go to File > Export > Export As...)
  3. In the Export As dialog, make sure all the layers are selected and adjust settings for format, size, etc. as desired

 

If you need more than one layer exported, then you can group it with another layer and select the group instead of an individual layer when you select Export As...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2023 Jan 07, 2023

Copy link to clipboard

Copied

@Myra Ferguson, it appears that @Flo98A1 has gone AWOL...

 

quote

But as I reread your question, it sounded like the layer comps may be made of single layers. If that's the case, then the simplest way to export them individually would be to do the following:

 

I don’t believe that is the case, there are other layers and layer groups that also need to be visible with one layer at a time from the images layer group included:

 

1.png

 

Screenshot 2022-12-29 at 11.41.53.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

@Flo98A1 

 

Try this script, it will automatically create a layer comp named after the layer for each child layer found in the currently selected/active parent layer group. A single undo step is offered if you need to undo all of the comps in one go. A quick test for 3 comps created manually was around 8 seconds, vs. around 0.1 of a second for the script (obviously less tedious as well).

 

/*
Create Layer Comps From Selected Parent Group Child Layers.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/way-to-turn-on-the-next-hidden-layer-to-automate-comps/td-p/13450230
v1.0 30th December 2022, Stephen Marsh
*/

#target photoshop

if (documents.length) {

    function main() {
        //if (activeDocument.activeLayer.typename === "LayerSet") {
        // Check for active layer group and case sensitive name of 'images'
        if (activeDocument.activeLayer.typename === "LayerSet" && activeDocument.activeLayer.name === "images") {

            // Setup the script timer
            var timeDiff = {
                setStartTime: function () {
                    d = new Date();
                    time = d.getTime();
                },
                getDiff: function () {
                    d = new Date();
                    t = d.getTime() - time;
                    time = d.getTime();
                    return t;
                }
            };
            timeDiff.setStartTime();

            // Set the current layer comp count
            var initialCompsCount = activeDocument.layerComps.length;

            /*
            // All child layers in the parent group should be hidden before comps are created
            for (var i = 0; i < activeDocument.activeLayer.layers.length; i++) {
                activeDocument.activeLayer.layers[i].visible = false;
            }
            */

            // Loop over the contents of the selected layer group and make layer comps
            for (var i = 0; i < activeDocument.activeLayer.layers.length; i++) {
                var layerName = activeDocument.activeLayer.layers[i].name;
                activeDocument.activeLayer.layers[i].visible = true;
                activeDocument.layerComps.add(layerName, undefined, true, true, true);
                activeDocument.activeLayer.layers[i].visible = false;
            }

            // Calculate the new layer comp count
            var compsCreatedCount = activeDocument.layerComps.length - initialCompsCount;

            // End of script notification
            alert(compsCreatedCount + " Layer Comps Created!" + "\n" + "(" + timeDiff.getDiff() / 1000 + " seconds)");

        } else {
            alert("The selected layer isn't a layer group or isn't named 'images'!");
        }
        
    }
    activeDocument.suspendHistory("Create Layer Comps From Selected Parent Group Child Layers...", "main()");

} else {
    alert("A document must be open to run this script!");
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – Create Layer Comps From Selected Parent Group Child Layers.txt
  5. Rename the saved file extension from .txt to .jsx (i.e. Create Layer Comps From Selected Parent Group Child Layers.jsx)
  6. Install or browse to the .jsx file to run (see below)

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 01, 2023 Jan 01, 2023

Copy link to clipboard

Copied

@Flo98A1 – So how did the script go?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 09, 2023 Jan 09, 2023

Copy link to clipboard

Copied

LATEST

Sorry everyone I have been out of action for a while, sorry for not keeping up with the comments etc. I really do appreciate everyone's assistance. Will update as soon as I can! Thanks for all your help and again, sorry for going silent.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines