admin管理员组

文章数量:1123945

How would I get the layer index of the layer in the document?

Here is my existing code:

    function getLayerInfoAtIndex(app, index) {
        try {
            app.echoToOE("start of getLayerInfoAtIndex");
            var document = app.activeDocument;
            app.echoToOE("2 part of getLayerInfoAtIndex");
            var numberOfLayers = document.layers.length;
            app.echoToOE("numberOfLayers=" + numberOfLayers);

            for (var i = 0; i < numberOfLayers; i++){
                var currentLayer = document.layers[i];
                var layerName = currentLayer.name
                app.echoToOE("layerName=" + layerName);
                var layerIndex = currentLayer.index;
                var layerIndex2 = currentLayer.layerIndex;
                app.echoToOE("layerIndex=" + layerIndex);
                app.echoToOE("layerIndex2=" + layerIndex2);

                if (layerIndex == index){
                    app.echoToOE("found layer at index = " + index);
                }
                else if (layerIndex2 == index){
                    app.echoToOE("2 found layer at index = " + index);
                }
            }
        }
        catch(error) {
            app.echoToOE("error" + error.message)
        }
    }

I pass this message to Photopea and I get the following:

I don't know how or where I'm getting the objects. But they are listed and they seem to be the same object. Here's that object expanded:

Actually, I'd like to get as much layer info as possible but the layer index is currently the minimum I need to get.

本文标签: photopeaHow to get the layer index of the layerStack Overflow