Skip to main content
Inspiring
October 25, 2022
Question

Paste in place script

  • October 25, 2022
  • 2 replies
  • 2450 views

Long time Photoshop scripter, first time Illustrator scripting.

 

I'm trying to paste an object in place. I would expect there to a method that's similiar to "paste"

app.pasteInPlace(); // won't work
app.paste.inPlace(); // and neither does this

...or something similar.

I've used the work around of 

app.executeMenuCommand("pasteInPlace");

My question is this: Is there a dot method way of pasting in place which has eluded me? Ive checked Illustrator JavaScript Scripting Reference, but that only has 2 references to paste. That would seem more programatical then relying on macros of menu commands.

2 replies

Participant
March 30, 2024

[EDIT]

[ script removed as it is not relevant to illustrator ]

 

[ post again if you have an actual Illustrator Scripting question ]

 

CarlosCanto
Community Expert
Community Expert
October 25, 2022

app.paste() is all we have. Other than using pasteInPlace menu command, the other alternative is to use duplicate() and reposition, which is more work. Or moving the view, which is also more work.

 

What are you trying to do? paste into different artboards?

Inspiring
October 25, 2022

Write a two line script (copy & paste in place) as a duplicate subsitute, to put on a keyboard shortcut.

 

m1b
Community Expert
Community Expert
October 25, 2022

Try this for the script:

 

for (var i = app.selection.length - 1; i >= 0; i--)
    app.selection[i].duplicate();

 

 - Mark

 

Edit: if you want just the duplicate item(s) selected:

for (var i = app.selection.length - 1; i >= 0; i--) {
    app.selection[i].duplicate();
    app.selection[i].selected = false;
}