2 Replies Latest reply on Aug 19, 2014 2:27 AM by nicolas@paperchefs.com

    Moving ruler origin, setting reference point etc.

    nicolas@paperchefs.com

      Hi,

       

      I'm quite new to scripting InDesign. I'm doing a script that moves and duplicates various page items. My problem comes in when the user has moved the ruler origin it messes up my script.

       

      How, within a script, can you set the ruler origin back to the top left of the page/spread?

       

      Also, when using a pageItem.move(to) method or pageItem.duplicate(to) method, how do you know whether you're using a top-left reference/anchor point or a centre-centre reference point etc?

       

      Thank you!

       

      Nicolas

        • 1. Re: Moving ruler origin, setting reference point etc.
          [Jongware] Most Valuable Participant

          1. RulerOrigin sets whether the ruler is relative to the page or spread (or spine, which I heartily dis-recommend for normal use ...). This enumeration is used (see the bottom) in 'ViewPreference.rulerOrigin', and 'ViewPreference' in turn is used as "Document.viewPreferences". That gives you the line

           

          app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
          

           

          This sets the relative position. The absolute zero point can be set through a document property: Document.zeroPoint ("The ruler origin, specified as page coordinates in the format [x, y]"):

           

          app.activeDocument.zeroPoint = [ 0,0 ];
          

           

          2. The methods that need a proxy location all accept an AnchorPoint, which can be one of the "Left", "Top", "Right Center" and so on as in the on-screen proxy.

          But if you check the PageItem,move command, you can see there is nothing there on 'anchor point'. It seems this command only uses the top left anchor for "to" (for movement by it's irrelevant which corner you use). The same is true for PageItem.duplicate.

           

          If you want to experiment and play around a bit, you can read the 'current' setting from the Control Panel as "LayoutWindow.transformReferencePoint":

           

          alert ("Current setting is "+app.layoutWindows[0].transformReferencePoint);
          

           

          which shows either one of the long numbers on AnchorPoint, or for newer versions of InDesign, if I'm not mistaken, the full name.