• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to change the reference point in InDesign using ExtendScript?

New Here ,
Nov 15, 2022 Nov 15, 2022

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.

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 15, 2022 Nov 15, 2022

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:

 

Screen Shot 16.png

 

Are you looking for this?:

Screen Shot 17.png

 

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]);

Votes

Translate

Translate
Community Expert ,
Nov 15, 2022 Nov 15, 2022

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;

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 15, 2022 Nov 15, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2022 Nov 15, 2022

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:

 

Screen Shot 16.png

 

Are you looking for this?:

Screen Shot 17.png

 

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]);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2022 Nov 16, 2022

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2022 Nov 16, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2022 Nov 16, 2022

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 )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2023 Nov 17, 2023

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.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2023 Nov 17, 2023

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:

https://community.adobe.com/t5/indesign-discussions/javascript-how-to-scale-an-image-using-a-script/...

 

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 18, 2023 Nov 18, 2023

Copy link to clipboard

Copied

LATEST

You have to reference a layout window, which you don't have if you don't have an open document.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2023 Nov 17, 2023

Copy link to clipboard

Copied

You can't. But you could of course create a document, set the refeence point, and discard the document.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2023 Nov 17, 2023

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2023 Nov 17, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines