Thats a beginner question...
Layers is property of Document, right? Pages, spreads and masterSpreads doesn't have this property.
So if there is a 3 layers in Doc and some stacks of PageItems set on, say, masterSpread - 20 pageItems on every layer - so there is 60 in total inside a Doc.
Doc.layers.pageItems.length == 0 and Doc.masterSpreads.pageItems.length == 60 (in this example).
How to create collection of pageItems from Doc.masterSpreads but only from a Doc.layers?
I can create an Array when open for...loop and push pageItems which pageItem.itemLayer.name == "name"
but is there a simple way to refer to collection of object in one line?
We recently had that subject. See:
And you are right.
You have to do the for loop to isolate all objects of a specific layer if targeting master spreads.
It's still not clear if it's a "feature", a "bug" or a "design choice" by the developers that we cannot reach objects on master pages if we ask for "document.layer.pageItems.everyItem()".