How can I find number of objects in a layer?

I have a document with hundreds of layers. I want to delete the specific purpose of layers. I iterate through all the layers, but I couldn't iterate over objects within a single layer to find that specific object.

I there a way I can go through all objects in the layer?

or

How can I find number of objects in a layer?

I'm going through the API documents but could not find.

Here is the code I wrote,

var artLayer = undefined;
        if(app.documents.length == 0)
        {
            app.documents.add();
        }
        var myDocument = app.activeDocument;
        var layerCount = myDocument.layers.length;
        
        
        for (var index = layerCount - 1; index >= 0; index-- ) 
        {
            var targetLayer = myDocument.layers[index];
            var layerName = new String( targetLayer.name );
            if(layerName == "Colorways")
            {
                artLayer = myDocument.layers[index];
               
                //Can I iterate through objects in a layer??
//                for(var newIndex = 0; newIndex < artLayer.items.length;newIndex++)
//              {
//                    Need something like this
//                }


                break;
            }
        }

instead of points, you should use "pageItems.

for (newIndex var = 0; newIndex)< artlayer.items.length;newindex++)="" there="" is="" no="" "items"="">

for (newIndex var = 0; newIndex)<>

or as in your second post, instead of the activeDocument, target your layer

index

index

Tags: Illustrator

Similar Questions

Maybe you are looking for