Skip to main content
Participating Frequently
January 23, 2024
Answered

Script to position an object on a page

  • January 23, 2024
  • 1 reply
  • 1109 views

When I paste an object on a page I need to reposition it to get to an exact X and Y position. I am doing this manually on a few hundred pages because the pasted object never falls in the right position, and to alter the X and Y each time is very time consuming.

Is there a scripting solution that will allow me to click on the object and run the script so that it positions the object to the desired X/Y coordinates? I cannot find one that has already been written.  In summary, I want to click on the object and then run a script that positions it at  X = 105.75mm and Y = 76.754mm. Can anyone help please? 

This topic has been closed for replies.
Correct answer Peter Kahrel
app.selection[0].move (['105.75mm', '76.754mm']);

A better solution would be to create an object style and make it the default style for graphics (or text, whichever your pasted objects are). In the object style you set the location, and on pasting the object should be placed correctly.

 

It would be even easier if there's an alyernative to pasting the object, such as duplicating it.

1 reply

Peter KahrelCorrect answer
Adobe Expert
January 23, 2024
app.selection[0].move (['105.75mm', '76.754mm']);

A better solution would be to create an object style and make it the default style for graphics (or text, whichever your pasted objects are). In the object style you set the location, and on pasting the object should be placed correctly.

 

It would be even easier if there's an alyernative to pasting the object, such as duplicating it.

A2D2
Inspiring
September 18, 2024

Hi,

 

Thank you for the post! I am often finding the need to move text frames on a long document where the margins have been changed or the document wasn't setup properly to begin with (i.e. the master pages) 

 

I note a relevant post elsewhere on the forum: How to reposition linked text frames?

 

quote
 app.selection[0].move (['105.75mm', '76.754mm']);

 

 

 

What would the script be if I wanted to move frames in position [x1, y1] to [x2, y2] AND frames in position [x3, y3] to [x4, y4]?

 

For example, condsider a book document where all the frames are out of position -- the verso frames need to be treated in one way and the recto frames in another.

quote

A better solution would be to create an object style and make it the default style for graphics (or text, whichever your pasted objects are). In the object style you set the location, and on pasting the object should be placed correctly.

 

I cannot see "location" in the object styles ... is this a feature available in newer versions of InDesign?

The following image shows the Object Styles dialogue in my version.

 

 

I am using CS6 (InDesign 8.0), Windows 11