2 Replies Latest reply on Nov 16, 2010 2:57 PM by Loic.Aigon

    [JS CS4] define a selection area

    Loic.Aigon Adobe Community Professional

      Hi all,

       

       

      I have to isolate repetitive areas in documents of hundreds of pages. My intention is to select the items located in this area.

      I wrote a while ago a script to find an item at xy location but this time, x & y will always be different and I can't imagine trying to catch items randomly until the script finds something.

      So I thought that maybe I could mimic the selection arrow and drag a selection area from x1y1 to x2y2 to select what's inside that field. My first guess is that js is not enough to do that so I guess it's more c++ related but I am not even sure.

      Does someone have any clue on that ?

       

      TIA

      Loic

        • 1. Re: [JS CS4] define a selection area
          [Jongware] Most Valuable Participant

          Piece of cake, Loic.

           

          selectInRectangle (app.activeWindow.activePage, 5,10, 120,100);
          
          // Maybe x,y,wide,high would work better?
          function selectInRectangle (source, x1,y1, x2,y2)
          {
               var it;
               
               app.select(null);
               for (it=0; it<source.pageItems.length; it++)
               {
               //     Only select all inside:
                    if (source.pageItems[it].geometricBounds[0] >= y1 &&
                         source.pageItems[it].geometricBounds[1] >= x1 &&
                         source.pageItems[it].geometricBounds[2] <= y2 &&
                         source.pageItems[it].geometricBounds[3] <= x2)
                         source.pageItems[it].select (SelectionOptions.ADD_TO);
               }
          }
           
          

          • 2. Re: [JS CS4] define a selection area
            Loic.Aigon Adobe Community Professional

            Very tasty cake indeed !

             

            Thanks a lot Jongware, I was going little by little to this scenario but your 2 billions kilometers per hour brain got it quicker

             

            Loic