1 Reply Latest reply on Mar 8, 2012 3:11 AM by Techi Panda

    sorting graphic frames

    Techi Panda Level 2

      Hi experts

       

      I want to sort all the graphic frames in current page by "Z" (Left to right and top to bottom) alignment.

       

      Here is screen shot of my page

       

      new1.JPG

       

      I want to sort these frames like this sequence.

       

      new2.JPG

       

      I have started with this but strucks on sorting items. Anyone tried this before or any suggestion to complete this?

       

      var myPages = app.activeDocument.pages;

      for (var p = 0; p < myPages.length; p++)

      {

      var myGraphic=app.activeDocument.pages[p].allGraphics;

      if(myGraphic.length>0)

      {

      var myg = [];

      for (var i=0; i<myGraphic.length; i++)

      {

      myg.push(myGraphic[i].parent);

      app.selection = myg;

      }

      }

      }

       

      Thanks in advance

       

      Regards

      arul

        • 1. Re: sorting graphic frames
          Techi Panda Level 2

          Hi All

           

          Finally done with small changes with John Hawkinson Script.

           

          Thanks John Hawkinson.

           

          function byYX(a,b) {

              var

                  aY = a.geometricBounds[2],

                  bY = b.geometricBounds[2],

                  aX = a.geometricBounds[3],

                  bX = b.geometricBounds[3],

                  dy = bY-aY,

                  dx = bX-aX;

           

              return dy?dy:dx;

          }

           

          var blocs = app.selection;

          blocs.sort(byYX);

           

          Regards

          arul