Skip to main content
m1b
Community Expert
Community Expert
Mar 5, 2024 9:26 AM UTC
Question

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

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.

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

m1b
Community Expert
m1bCommunity ExpertAuthor
Community Expert
Mar 7, 2024 9:34 PM UTC

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

Translate
Inspiring
Sep 11, 2024 1:45 PM UTC

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.

Translate
m1b
Community Expert
m1bCommunity ExpertAuthor
Community Expert
Sep 11, 2024 10:45 PM UTC

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!

Translate
Marc Autret
Legend
Mar 7, 2024 4:53 PM UTC

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

Translate
m1b
Community Expert
m1bCommunity ExpertAuthor
Community Expert
Mar 7, 2024 9:29 PM UTC

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

Translate