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

examples of the move method in scripting / move object to a specific page

New Here ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

edit: I figured it out everybody. please disregard this thread.

 

Hi

 

I am having trouble understanding the Move Method in Indesign scripting with javascript. I can move objects around on the page but i want to be able to move an image to a specific known page number.

 

var myRectangle = app.selection[0]

myRectangle.move(["1in", "1in"]);

 

that code works but i want to be able to move the rectangle to a different page.....

 

was looking for some help/examples...

 

Kindly,

Mark

 

TOPICS
Scripting

Views

2.1K

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 , Apr 11, 2020 Apr 11, 2020

Hi Mark,

method move() and also method duplicate() have two arguments.

The to and the by argument. If you do only one argument the to argument is used.

What are the capabilities of the to argument?

 

This depends on the object you want to move. Is it text, is it a page, is it a graphic frame or text frame?

Your sample is assuming that you selected a rectangle graphic frame. So look up method move() with object rectangle in DOM documentation: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html#d1e217191__d1e220631

...

Votes

Translate

Translate
Community Expert ,
Apr 11, 2020 Apr 11, 2020

Copy link to clipboard

Copied

LATEST

Hi Mark,

method move() and also method duplicate() have two arguments.

The to and the by argument. If you do only one argument the to argument is used.

What are the capabilities of the to argument?

 

This depends on the object you want to move. Is it text, is it a page, is it a graphic frame or text frame?

Your sample is assuming that you selected a rectangle graphic frame. So look up method move() with object rectangle in DOM documentation: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html#d1e217191__d1e220631

 

And there you have them, several targets where you can move your rectangle to:

 

[ x , y ] Coordinates x and y given as array

Page

Spread

Layer

 

So define your target. If it is a page, let's say page 3 of your document, do it like that:

var targetPage = app.documents[0].pages[2];
var myRectangle = app.selection[0];
myRectangle.move( targetPage );

 

What can go wrong with that?

Hm. If the selected rectangle is nested. Means is part of a group, is pasted inside another graphic frame, is anchored to text, is part of a graphic cell. Come back if you have more issues with special cases like that…

 

Regards,
Uwe Laubender

( ACP )

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