Skip to main content
Simonetos The Greek
Inspiring
July 5, 2019
Answered

Where can I find the numeric list of layerKind?

  • July 5, 2019
  • 1 reply
  • 1134 views

I have this function which get some layers data and then do some stuff. If you see at line 24, there is an if condition "if (lyr.type == layerType" and for example, if I want to choose shape layers I have to put the number 4 using a prompt. My question is, where does this number come from? Why 4? What is 3 or 5? Where can I find a list of what is what?

Thank you for your time!!!

function getLayersData()

    {

        var lyrs = [];

        var layers = 1;

        while (true)

        {

            ref = new ActionReference();

            ref.putIndex(charIDToTypeID('Lyr '), layers);

           

            try

            {

                var desc = executeActionGet(ref);

            }

            catch (err)

            {

                break;               

            }

           

            var lyr = {};

            lyr.type = desc.getInteger(stringIDToTypeID("layerKind"));

            lyr.name = desc.getString(charIDToTypeID("Nm  "));

            lyr.id = desc.getInteger(stringIDToTypeID("layerID"));

           

            if (lyr.type == layerType && lyr.name.match(layerName))

            {

                var adj = desc.getList(stringIDToTypeID("adjustment")).getObjectValue(0);

                if (adj.hasKey(stringIDToTypeID("color")))

                {

                    var curColor = new SolidColor();

                    curColor.rgb.red = adj.getObjectValue(stringIDToTypeID("color")).getUnitDoubleValue(stringIDToTypeID("red"));

                    curColor.rgb.green = adj.getObjectValue(stringIDToTypeID("color")).getUnitDoubleValue(stringIDToTypeID("grain"));

                    curColor.rgb.blue = adj.getObjectValue(stringIDToTypeID("color")).getUnitDoubleValue(stringIDToTypeID("blue"));

                    lyr.color = curColor;

                    if (lyr.color.rgb.hexValue == currentColor[0])

                    {

                        lyrs.push(lyr);                                       

                    }                     

                }               

            }

            layers++;           

        }

        return lyrs       

    };

This topic has been closed for replies.
Correct answer r-bin

I found these six basic types of layers. I leave them here if someone else need them and if I found more I'll post them...

1 for pixel layers.
2 for adjustment layers.
3 for text layers (or type layers).

4 for shape layers.

5 for smart object.

7 for groups or artboards.


Re: Is there description of the numeric 'layerKind' indexes that are available through AM?

1 reply

Kukurykus
Legend
July 5, 2019

You can't without trying. In Domestic Oriented Model they are specified but not by Action Manager.

Simonetos The Greek
Inspiring
July 5, 2019

I am not sure if I get what you mean...

Kukurykus
Legend
July 5, 2019

DOM is based on AM, and thanks to favour or creators in that first there are used names instead of numbers.