Skip to main content
patrickw91487713
Participant
May 13, 2020
Answered

PageItem Index across all Frametypes

  • May 13, 2020
  • 2 replies
  • 952 views

The field "Index" of PageItem in JS is relative to the Type. Therfore for 3 TextFrames and 3 Rectangles the Index is 0,1,2 and again 0,1,2. This applies to all different Types. 

But somehow InDesign and InDesign Server still know which Frame has higher z-index even if they have the same number. 

Example: Textframe with index 5 can be in front of Rectangle with index 5. If i tell it to move one up, it still has index 5 but is now in front of the Rectangle.

 

Is there a way to get the Index across all the Frames and Frametypes? 

 

I already have a solution thats works by duplicating the frames and grouping them. On this approach, everything will be a Group and i can take this Index. But this is way to complicated. There needs to be another way to get this.

This topic has been closed for replies.
Correct answer Laubender

Hi Patrick,

the allPageItems array of a spread will give you the z-order.

If you loop that array exclude all items which parent value is not the spread.

 

Regards,
Uwe Laubender

( ACP )

2 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
May 13, 2020

Hi Patrick,

the allPageItems array of a spread will give you the z-order.

If you loop that array exclude all items which parent value is not the spread.

 

Regards,
Uwe Laubender

( ACP )

patrickw91487713
Participant
May 13, 2020

Hi,

 

allPageItems is correct. I updated my Image to show the new result.

 

Thank you and best Regards,

 

Patrick

 

BarlaeDC
Community Expert
Community Expert
May 13, 2020

HI,

 

As textframes and rectangles are pageitems, could you not use the page items list to find out the order of them as it also has a index property.

Regards

Malcolm

patrickw91487713
Participant
May 13, 2020

Hi,

I've already checked the pageItems collection order, so basically the value of i in:

 

  for (var i = 0; i < pageItems.length; i++) {
         var pageItem = pageItems[i];
         pageItem.index; // Index in my Screenshot
         i; // CollectionIndex in my Screenshot

 

 It does not follow the z-index. My guess would be that its sorted in the order or creation.

Screenshot with the values:

 

 

BarlaeDC
Community Expert
Community Expert
May 13, 2020

Hi,

 

Curses, thought that might be a quick fix, will investigate.

Regards

Malcolm