3 Replies Latest reply on Oct 20, 2013 3:20 AM by BEGINNER_X

    Globally change "X+" location of multiple images in graphics frames

    Saki H Level 1

      I have ~120 images that were imported using data merge with an "X+" value of –0.000 in. I would like to change this value to 0.250 in for all of these images. I couldn't figure out how to do this with "Find/Change" and my experience with scripting is minimal. Would anyone by chance know of (be willing to share) a script that could help me do this?

       

      Thanks in advance.

        • 1. Re: Globally change "X+" location of multiple images in graphics frames
          BEGINNER_X Level 3

          Hi Neil,

           

          Use the below code, it may helpful for you

           

           

          var myDoc = app.activeDocument;
          
          var myGraphics = myDoc.allGraphics;
          
          //~ alert(myGraphics.length)
          
          app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.INCHES;
          app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.INCHES;
          
          for(i=0; i<myGraphics.length; i++)
          {
              var myBounds = myGraphics[i].geometricBounds;
              myGraphics[i].geometricBounds = [myBounds[0],myBounds[1]+0.250,myBounds[2],myBounds[3]];
              }
          

           

           

          Thanks

          Beginner_X

          1 person found this helpful
          • 2. Re: Globally change "X+" location of multiple images in graphics frames
            Saki H Level 1

            Thank you so much. This is great! When I first tried this script, the x-location shifted by 0.250, but the width decreased by the same amount. However, I added "0.250" after "myBounds[3]" and now it keeps the same dimensions. Just to clarify, the line I changed now reads:

             

                myGraphics[i].geometricBounds = [myBounds[0],myBounds[1]0.250,myBounds[2],myBounds[3]0.250];

             

            However, I realize that I left out a piece of pertinent information in my original post. The 120 figures that need to shift are only 1/3 of the total number of figures in the file. To clarify, the file has 120 spreads with 3 figures on each spread (2 on the left page and 1 on the right page), and I only want to change the bottom figure on the left page. The layout for all pages uses the same master page layout and was created through a data merge. Is it possible to isolate only the figures on the bottom of the left page? The relevant text frames are all at X=5.269 in and Y=6.2552 in and reference point=upper left corner, so I am wondering if it might be possible to use that information to identify the relevant figures. But I am not sure how to do that.

             

            Thanks again for your help,

            Neil

            • 3. Re: Globally change "X+" location of multiple images in graphics frames
              BEGINNER_X Level 3

              Hi Neil,

               

              Thanks for your feedback....

               

              Could you please try this code also, may it will be helpful:

               

              var myDoc = app.activeDocument;
              
              app.activeWindow.transformReferencePoint = AnchorPoint.TOP_LEFT_ANCHOR;
              
              app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.INCHES;
              app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.INCHES;
              
              var myGraphics = myDoc.allGraphics;
              //~ alert(myGraphics.length)
              
              for(i=0; i<myGraphics.length; i++)
              {
                  var myBounds = myGraphics[i].geometricBounds;
                  alert("myBounds:" + myBounds)
                  
                  if(myGraphics[i].geometricBounds[1] == 5.269 || myGraphics[i].geometricBounds[0] == 6.2552)
                  {
                  myGraphics[i].geometricBounds = [myBounds[0],myBounds[1]+0.250,myBounds[2],myBounds[3]+0.250];
                  }
                  }
              

               

              Thanks

              Beginner_X