Copy link to clipboard
Copied
Hi,
Is it possible to convert a selection index to a pageItem index?
For instance, if my selection is sel[0] what corresponding pageItem[?] is that selection?
Javascript has a getIndex function but it doesn't work in ExtendScript it seems.
Thanks!
I think you have to iterate all the top level pageItems and check each pageItems[i] as to whether it references the same selected object.
Copy link to clipboard
Copied
I think you have to iterate all the top level pageItems and check each pageItems[i] as to whether it references the same selected object.
Copy link to clipboard
Copied
Hi,
Yes that did work thank you. I've created a simple function for this if anyone is interrested:
function findIndexInSelection(pageItems, selectionIndex){
var doc = app.activeDocument;
var sel = doc.selection;
for (i=0;i<pageItems.length;i++){
if (pageItems[i] == sel[selectionIndex])
return i;
}
}