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

How to automate exporting different layer combinations?

Community Beginner ,
Jul 04, 2019 Jul 04, 2019

Hi, I want to know how to export different layer combinations. I'm setting up character sprites for a video game, and I would like to mix and match different facial parts to make a variety of expressions.

Here is how the layers are set up:

layer-show.PNG

This is how the folders look when opened:

open.PNG

The idea is to mix and match these parts to create different expressions. For example:

openSmile_shiny-iris-normal_downward.PNG smile_closed_raised.PNG

These are two possible combinations out of 216 total.

I tried to use this script: GitHub - mechanicious/photoshopCompositionComposer: Automate the process of creating design composit...

However, it would always export only the first 2 combinations. I spent quite a few hours trying to get it to work. The "Layer Composition" feature is near useless, as I have to make every possible combination visible, then save it. Is there a way to automate this? Thank you!

5.3K
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 05, 2019 Jul 05, 2019

You are right for automation, it can be done even using actions but is it worth? Perhaps if you need for at least several characters to animate, otherwise you will spend more time recording action then creating layer comps. If you have lots of similar files then I can try to explain to you how to record action but keep in mind that every file must have layers with exact same names or at least same order and same layer count in order to record action for such task. It is worthless even to think a

...
Translate
Adobe
Community Expert ,
Jul 04, 2019 Jul 04, 2019

Have you tried with Window > Layer Comps to save layer comps with different expressions then to save them as separate files using File > Export > Layer Comps to Files?

There is no other way to explain to software what you want using built in features, at least from what I know about that topic.

Translate
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 ,
Jul 04, 2019 Jul 04, 2019

You would need to design some Process that cans be scripted to produce the output file you want. Like use the layer stacking order within groups. Where only one layer in each group will be visible in the output character image. First the top layer in each group on  and output a character sprite.Then them off and next one down the stack on. The output filename would  character name + first group layer name.  There need to be some logical way to know which layers should be in visible for each of the 216 sprite ,

Or create 216 layer comps for each character document and export layer comps to files

JJMack
Translate
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 ,
Jul 05, 2019 Jul 05, 2019

You are right for automation, it can be done even using actions but is it worth? Perhaps if you need for at least several characters to animate, otherwise you will spend more time recording action then creating layer comps. If you have lots of similar files then I can try to explain to you how to record action but keep in mind that every file must have layers with exact same names or at least same order and same layer count in order to record action for such task. It is worthless even to think about with only one file in question.

If nothing else, you can automate layer comp creation. Record action to create layer com and assign keyboard shortcut to play action. Manage layer visibility then play action... You can also turn on modal for Make layer comp step to be able to name layer comp or just record step and play action which will be creating layer comps with generic names.

Translate
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 ,
Jul 08, 2019 Jul 08, 2019

I tried to write a script, but I really struggle with Photoshop... I have JS experience but Photoshop script is hard for me.. dont know why. Anyway, thank you for your replies, I will keep trying.

Translate
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
LEGEND ,
Jul 09, 2019 Jul 09, 2019

You can walk through the layers with a script using a loop, and show/hide layers as you go. Leave the base layer on and turn on and off the ones you want varied, then export.

Translate
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
LEGEND ,
Jul 09, 2019 Jul 09, 2019

This is a script I use to export text layers to a file. Note the for loop and test for LayerKind. Your script would have different logic but otherwise be similar.

#target photoshop

textCopier2();

function textCopier2(){

    if(documents.length > 0){

        var originalDialogMode = app.displayDialogs;

        app.displayDialogs = DialogModes.ERROR;

        try{

            var fleLogFile2 = new File('~/Desktop/textExport2.txt');

            fleLogFile2.open('a:');

            for(var j = 0; j < documents.length; j++){

                var docRef = documents;

                var exportLine = docRef.name;

                for(var i = 0; i < docRef.artLayers.length; i++){

                    var LayerRef = docRef.artLayers;

                    if(LayerRef.kind == LayerKind.TEXT){

                        var layerText = LayerRef.textItem.contents;

                        layerText = layerText.replace('\r', ',');

                        layerText = layerText.replace(/,/g, '\r' + exportLine + '\t');

                        exportLine = exportLine + '\t' + layerText;

                        fileWriter2();

                        }

                    }

                }

            function fileWriter2(){

                fleLogFile2.writeln(exportLine);

                exportLine = docRef.name;

                }

            fleLogFile2.close();

            }

        catch(e){

            alert(e + e.line);

            }

        app.displayDialogs = originalDialogMode;

        }

    }

Translate
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
Explorer ,
Sep 07, 2021 Sep 07, 2021
LATEST
Translate
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