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

[Scripting] How can I position a page item in "layoutWindow" coordinates?

Community Expert ,
Mar 05, 2024 Mar 05, 2024

Copy link to clipboard

Copied

Hi all,

I'm hoping someone can help me—I want to position a page item in the layout window, eg. in the center of the window, but preferably anywhere in the window.

 

Constraints are:

1. Do not disturb the layout window (or if you do, put it back exactly), and

2. Do not disturb the clipboard.

 

Is this possible?

- Mark

 

P.S. I was wondering if CoordinateSpaces might extend to the layoutWindow, but it doesn't seem to. @Marc Autret I would be grateful to hear your thoughts as I know you've done a lot of work in this area.

TOPICS
Scripting

Views

178

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
Guide ,
Mar 07, 2024 Mar 07, 2024

Copy link to clipboard

Copied

Hi Mark,

 

Difficult question! Of course the LayoutWindow object has bounds, but they are expressed in screen coordinates and (to my knowledge) there is no mapping from screen space to DOM coordinate spaces. These are totally different beasts.

 

I haven't explored the question further, but perhaps an approach would be to create a transformation matrix yourself, at a specific time, from a known state of the ‘viewport’. For example, when you run View > Entire Pasteboard you get some fixed view that forcibly contains the whole active spread (and a few more pixels around!). At this particular time and zoom percentage, there is a virtual connection between the window bounds and the spread coordinate space, something like [k, 0, 0, k, tx, ty] in terms of transformation matrix.

 

This solution seems extremely fragile though. Furthermore, it does not meet your goal (constraint 1) which implies that the screen↔DOM mapping should be determinated from any view state. Looks like a very hard problem 😞

 

Best,

Marc

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 ,
Mar 07, 2024 Mar 07, 2024

Copy link to clipboard

Copied

Thanks a lot for considering my question Marc. I suspected that would be the anwer. - Mark

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 ,
Mar 07, 2024 Mar 07, 2024

Copy link to clipboard

Copied

Hi all, I have made a feature request for this. I suggested just a simple method of LayoutWindow that aligns the layoutWindow's viewport's center with a point in document coordinates—this is what Illustrator does. Combining this with zoom, which we already have, will be enough for my purposes.

 

If you would like to see this feature, please vote.

- Mark

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
Participant ,
Sep 11, 2024 Sep 11, 2024

Copy link to clipboard

Copied

Interesting. Screenspace coordinates like this could also be used to snap dialog windows to pageItems. I came here by googling if a dialog can be made to position itself over a frame.

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 ,
Sep 11, 2024 Sep 11, 2024

Copy link to clipboard

Copied

LATEST

Hi @Stephan Moebius, I think for this purpose we would need, as Marc discussed, a way of mapping between DOM coordinate space(s) and screen coordinates. I would like to see that, too!

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