• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Selection Index to pageItem Index?

Participant ,
May 15, 2023 May 15, 2023

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!

TOPICS
Scripting

Views

373

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , May 15, 2023 May 15, 2023

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. 

Votes

Translate

Translate
Adobe
Guide ,
May 15, 2023 May 15, 2023

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 15, 2023 May 15, 2023

Copy link to clipboard

Copied

LATEST

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;
  }
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines