4 Replies Latest reply on Oct 23, 2013 9:52 AM by Jump_Over

    How to change group indices

    steve.carey

      I am writing a script (in VB) to fill out a catalogue page (or several pages). The page is filled with blank catalogue entries, each of which is a group of text frames and image frames. One field is manually typed in and the rest is autofilled form an XML file. After the data is filled in, the groups need shuffling down to fit on the page and where there is no space, they get moved to the next page. I rely on the user ordering the groups such that when the code iterates throguh the groups by index, the groups are worked through from the top of the page to the bottom. This works fine until I move a group to the next page. Moving a group means it gets added to the end of the list of groups. My question: is there a way to change the order of the groups (as they appear in the layers panel)?

       

      This problem would also arise if the user wanted to insert a new item into a already populated indesign file.

       

      Thanks

       

      Steve

        • 1. Re: How to change group indices
          AnshulJain19 Adobe Employee

          Hi Steve,

           

          Arranging Page Items

          Page items in an InDesign layout can be arranged in front of or behind each other by adjusting their stacking order within a layer, or can be placed on different layers. The following script fragment shows how to bring objects to the front or back of their layer, and how to control the stacking order of objects relative to each other.

          //Given a rectangle "myRectangle" and an oval "myOval",

          //where "myOval" is in front of "myRectangle", bring

          //the rectangle to the front...

          myRectangle.bringToFront();

          When you create a page item, you can specify its layer, but you can also move a page item from one layer

          to another. The item layeritemLayerItemLayer property of the page item is the key to doing this, as shown

          in the following script fragment (for the complete script, refer to ItemLayer).

          //Given a rectangle "myRectangle" and a layer "myLayer",

          //send the rectangle to the layer...

          myRectangle.itemLayer = app.Documents.item(0).layers.item("myLayer");

          The stacking order of layers in a document can also be changed using the move move method of the layer

          itself, as shown in the following script fragment (for the complete script, refer to MoveLayer).

          //Given a layer "myLayer", move the layer behind

          //the default layer (the lowest layer in the document

          //is layers.item(-1).

          myLayer.move(LocationOptionsafter, app.documents.item(0).layers.item(-1));

           

          Thanks

          -Anshul

          • 2. Re: How to change group indices
            steve.carey Level 1

            Thanks but that's not quite what I mean.

             

            When you look at a layer in the layers panel, it contains, let's say, 5 groups. Those groups are assigned an index from 1 to 5 with 1 being the group at the top of the list and 5 being the one at the bottom. I want to be able to take the group at the bottom of the list and move it to the top. It's like you have described with changing the layer order but with groups wtihin a layer instead. The Move function just allows moving a group to another location on the page, not changing its order in the list.

             

            Steve

            • 3. Re: How to change group indices
              AnshulJain19 Adobe Employee

              For that purpose you can use following;

              myGroup.bringForward();

              or

              myGroup.bringToFront();

              or

              myGroup.sendBackward();

              or

              myGroup.sendToBack();

              • 4. Re: How to change group indices
                Jump_Over Level 5

                Hi,

                 

                As AnshunJain19 wrote:

                 

                myRectangle.bringToFront();

                 

                     brings myRectangle to the top of the layer if no parameter specified.

                 

                myRectangle.bringToFront(myOval);

                 

                     brings myRectangle in front of myOval

                 

                If they are not on the same layer ==> use move method to equal layers first and bringToFront() - or sendToBack() - to set order.

                 

                Jarek