Skip to main content
Known Participant
August 19, 2014
Answered

Moving ruler origin, setting reference point etc.

  • August 19, 2014
  • 1 reply
  • 2327 views

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

This topic has been closed for replies.
Correct answer Jongware

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.

1 reply

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
August 19, 2014

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.

nicolas7Author
Known Participant
August 19, 2014

Thanks so much!