Skip to main content
Participant
June 20, 2013
Question

Aligning Objects to X-Coordinates

  • June 20, 2013
  • 2 replies
  • 1824 views

Hi everyone,

I'm working on a project right now that requires me to select all elements on a page, and then align that selection to a x-axis coordinate; I know there's a 'SelectObjects' script that comes default with InDesign CS6, however, after running it and getting the selection made, I go and then run the 'Equalizer 2.0' script from indiscripts.com (it allows one to copy and paste x - y coordinates to elements or groups of elements); what happens, is that ALL elements get sent to the x coordinate, but disregarding the initial spacing between them in the selection. I even ran the 'AlignToPage' and the same thing happens: ALL elements move to x and ignore the original spacing between them.

If I make a manual selection of all elements on the page (or have 'SelectObjects' do it for that matter) and THEN manually change the x coordinate, the whole thing moves to said coordinate but keeping the original spacing between elements! I really don't know whats going on, and I'm really not as well versed in scripts as I should be; so my question I guess would be: any ideas??? I would greatly appreciate the help as this is for a client Im working for and would REALLY speed things up for me!!!

This topic has been closed for replies.

2 replies

Sergey_Anosov
Participating Frequently
June 21, 2013
Participant
June 21, 2013

OMG! Thats EXACTLY what I was looking for! Thank you so much!

These forums rock!!!

Sergey_Anosov
Participating Frequently
June 22, 2013

You are welcome!

Vamitul
Legend
June 20, 2013

sorry i don't have the time to write the script for you.

so...

after you have all your objects selected you just need a line:

myDocument.align(myDocument.selection,AlignOptions.HORIZONTAL_CENTERS,AlignDistributeBounds.ITEM_BOUNDS);

just replace myDocument with the variable you used for refereing to the active document.

Participant
June 20, 2013

Thank you so much for your answer! Could you really quickly explain the basics behind this? Is the key here to the elements preserving their relative positioning to each other the 'AlignDistributeBounds' part? or the HORIZONTAL_CENTER?? Again, thank you very much!