1 person found this helpful
collection.getElements(); //Returns an array.
But still items could be removed by your script and references later be non valid.
The strongest approach would be probably to store items id in a object as IDs don't change whatever you do in the meanwhile.
Oh, I see. So it’s not that the newly created elements are ‘unshifted’ onto the beginning of the collection, but rather that the entire collection gets recreated as soon as the element is created, and since the new element is in the same position as the old one, but on a higher layer (?), it ends up being the first in the new collection.
That actually makes a lot more sense!
Loic.Aigon wrote… The strongest approach would be probably to store items id in a object as IDs don't change whatever you do in the meanwhile.
But if you only want to duplicate elements an array will work. Duplicating elements cannot change the gathered array of page items.
var rectArray = app.documents.rectangles.everyItem().getElements();
Note: The array above will not contain rectangles in nested structures like groups or anchored frames etc.pp.