This content has been marked as final. Show 3 replies
You'll probably have to collect all page items on a page, then iterate through them checking what layer they're on. Something like this:
myPages = app.activeDocument.pages;
for (i = 0; i < myPages.length; i++)
p_items = myPages[i].allPageItems;
for (j = 0; j < p_items.length; j++)
case 'Layer 1': // do this
case 'Layer 2': // do that
case 'Layer 3': // do the other
allPageItems is not the right property to use. That includes page items that are grouped already or anchored to text. You should just use the pageItems collection if your plan is to group them.
Groups are constrained to be within a spread, so using the layers collection isn't likely to work, although it could if all the items on a particular layer were actually on a single spread.
I thought it might be complicated!