- doc.layers is a collection of all layers in document, regardless of the group it is in. This might not guarantee any order since they are "not in same list" (likely it's the order of layers-panel fully extracted). If you want to process layers in one group, you should use the .artLayers-collection
- I think Photoshop processes layers from "top to bottom", i.e. both "from top of screen to bottom" in layers-panel and "from topmost to bottom" in z-order. If you want the other way, start from bottom.
layers or artLayers gives me the same results.
Would the processing order matter when it's looking for a specific layer index? If the layer index is static wouldn't this script start with layer 0 (the bottom one)?
If your document has no groups, then doc.layers and doc.artLayers will be the same. But if you groups then doc.layers will give all
- art layers in the doc root
- the groups you have an doc root
- any art layers and sub groups in the root level groups.
I.e. doc.layers will return the full document hierarchy as a flat list, but the order that list is not guaranteed to be something (as far as I know). Most likely order is always the visual top to bottom. I.e. item 0 is always the visually topmost element.
Also note that if you use doc.layers, you need to check if the item is a layer or a group (=folder=layerset). That's why you also have the collections .artLayers and .layerSets that give just layers and groups respectfully.
Wouldn't that mean the collection numbers are in fact not static? Meaning the whole bit in the adobe introduction to scripting is wrong (again), or does the script check a different number than the one mentioned?
To be honest, I'm not sure I've not had to go deep in this area, mostly just iterate through the .artLayers and .layerSets and keep a reference to the object itself if needed.
Please don't use that document for Photoshop. I believe you are referencing the same Illustrator document that has known mistakes for Photoshop context.
For Photoshop use these documents from this link: Adobe Photoshop Scripting | Adobe Developer Connection
Those documents actually repeatedly point me to that document.
For example from Photoshop-CS6-Scripting-Guide.pdf:
"If you are new to scripting, you should acquaint yourself with the basic scripting information provided in the Introduction to Scripting manual."
So I figured I should start there, and as an introduction it isn't bad except for the few items that just don't seem to be true
I've finished that one so I'll move on to the proper Photoshop documents now.