2 Replies Latest reply on Oct 5, 2009 8:33 AM by Seth McGraw

    Equation help

    Seth McGraw

      I have the center point of a rectangle (frame). I need to center content in the frame, but I cant move things by any reference point other than top left. how can I calculate the top left indesign coordinates that a second rectangle would have to be placed at so that the center point matches the center point of the first rectangle?

      I have the script figured out except for the equation needed to find the point.



        • 1. Re: Equation help
          [Jongware] Most Valuable Participant

          Something like this? It will move 'b' to the center of 'a' by getting the difference between their center points.


          if (app.selection.length != 2)
           complain (loudly);
          a = app.selection[0];
          b = app.selection[1];
          // get center of a
          ax = (a.geometricBounds[1]+a.geometricBounds[3])/2;
          ay = (a.geometricBounds[0]+a.geometricBounds[2])/2;
          // get center of b
          bx = (b.geometricBounds[1]+b.geometricBounds[3])/2;
          by = (b.geometricBounds[0]+b.geometricBounds[2])/2;
          // move required distance
          b.move (undefined,[ax-bx,ay-by]);


          From this set-up you cannot know what 'a' is and what 'b', so it might work the other way around (moving a to the center of b), but I take it you already know what's to move within what else.

          • 2. Re: Equation help
            Seth McGraw Level 1

            Thanks for your help. Worked great.