1 Reply Latest reply on Apr 15, 2014 8:19 AM by Jump_Over

    Not understanding result of rectangle moving

    JonnyDL Level 1

      I'm building a script that will need to select some images, and move their image boxes (parent), to the left or the right.

       

      I have the script loop through an array of images(PDFs) in the document, and finds the ones I need by filepath

      once the image path matches the requsted path, I find (and select for visual conformation) the parent (rectangle) of the image.

      This all works. where my confusion lies is when it moves.

      when I move it the parent moves, but the image stays in position. When you select the parent manuallly in indesign and move it that way the rectangle and image move together.

       

      Why is this not working as expected.

       

       

       

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

        {

            var myCurrentimage = myDoc.pageItems.itemByID(imageArray[i]).itemLink.filePath;

            if (myCurrentimage==ServiceHeader_6col )

            {

       

                var headerUsed = myDoc.pageItems.itemByID(imageArray[i]).parent

               myDoc.select(headerUsed )

               var headerBounds = headerUsed.geometricBounds;

               alert(headerBounds);

               headerBounds[1] = 100

               headerBounds[3] = headerBounds [3]+100

               headerUsed.geometricBounds= headerBounds

             }

       

         }

        • 1. Re: Not understanding result of rectangle moving
          Jump_Over Level 5

          JonnyDL wrote:

           

          ...When you select the parent manuallly in indesign and move it that way the rectangle and image move together...

           

          Right but not when you drag parent controls to change parent's size (or position in fact).

          Resetting box.geometricBounds means dragging controls rather than move.

           

          Better way is to use move(to,[by]) method. In your case:

          headerUsed.move(undefined,[100,0]);
          

           

          Jarek