Copy link to clipboard
Copied
I want to move the upper right corner of a selection of items to a specific position. But at the moment the reference point of the selection of items is on the lower left corner.
app.selection[0].move([10, 10]);
Is there a way to change the reference point to the upper right corner in InDesign using ExtendScript?
Thank you for your help.
I want to set the position selection by setting the position of the upper right corner of the selection.
With app.selection[0].move([10, 10]); I always get this:
Are you looking for this?:
Subtract the width of the selection from x:
var doc = app.activeDocument
var s = app.selection[0];
var b = s.geometricBounds
var w = b[3]-b[1]
s.move([10 - w, 10]);
Copy link to clipboard
Copied
Hi @Alexander17 , the move() method is to x,y, so you shouldn’t have to set the reference point. Make sure the rulers are set to 0—does this work?:
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var doc = app.activeDocument
doc.zeroPoint = [0, 0];
doc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
app.selection[0].move([10, 10]);
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
Copy link to clipboard
Copied
The rulers and the measurement unit are not the problem. The rulers are set to 0 und the measurement unit is correct.
I want to set the position selection by setting the position of the upper right corner of the selection. But at the moment the reference point of the selection is the lower left corner.
Copy link to clipboard
Copied
I want to set the position selection by setting the position of the upper right corner of the selection.
With app.selection[0].move([10, 10]); I always get this:
Are you looking for this?:
Subtract the width of the selection from x:
var doc = app.activeDocument
var s = app.selection[0];
var b = s.geometricBounds
var w = b[3]-b[1]
s.move([10 - w, 10]);
Copy link to clipboard
Copied
I am looking for this. Thank you very much for your help. This works. But is there also a way to change the reference point of the selection before moving the selection?
Copy link to clipboard
Copied
> But is there also a way to change the reference point of the selection before moving the selection?
If you mean the reference point as you see it in the Transform panel, then yes:
app.windows[0].transformReferencePoint = AnchorPoint.TOP_RIGHT_ANCHOR
But this has nothing to do with the .move() method.
Copy link to clipboard
Copied
Hi @Alexander17 ,
also note that the position of the reference point that the GUI widget is showing of a selected object depends on the rotation angle of that object. This also has nothing to do with the .move() method.
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
To come back to the actual question: "How can I change the reference point in InDesign":
Manually, it's possible to change the standard reference point with _no_ document open, i.e. without a "Layout Window".
Is this also possibly by scripting? Or is also this lacking in the scripting API?
(Just as a side note: You can't set a text frame on a master page to be the "primary text frame" by script.)
Copy link to clipboard
Copied
I'm not sure, but I wonder if the last script by @rob day in this discussion will give you a hint:
Namely, this parameter: AnchorPoint.TOP_LEFT_ANCHOR
I don't know the final goal you pursue so it may have nothing to do with what you need.
Copy link to clipboard
Copied
You have to reference a layout window, which you don't have if you don't have an open document.
Copy link to clipboard
Copied
You can't. But you could of course create a document, set the refeence point, and discard the document.
Copy link to clipboard
Copied
Thanks a lot - yes, strange enough, but will do it this way.
I remember something similar - wasn't that the thing how to navigate to a URL?
Copy link to clipboard
Copied
That was a while ago! But yes, to navigate to a URL, place a text frame, enter a URL hyperlink, and follow that link.