Paste in place script
Copy link to clipboard
Copied
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.
Explore related tutorials & articles
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Write a two line script (copy & paste in place) as a duplicate subsitute, to put on a keyboard shortcut.
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
I would go with this then. There's nothing wrong with using Menu Commands
app.executeMenuCommand("copy");
app.executeMenuCommand("pasteInPlace");
Copy link to clipboard
Copied
Succinct and to the point! 🙂
Copy link to clipboard
Copied
right?!
(we might be missing something though)
Copy link to clipboard
Copied
I already have a two line script. - That wasn't what I was after.
app.copy();
app.executeMenuCommand("pasteInPlace");
I would apologise for the confusion, but I'm Autistic and written communication is just another way for me to be misheard or mis-understood.
I just find it very odd that Illustrator scripting seems to lack basic functionality at a low level. - Which is blatanly obvious even from teh two lines above.
Copy link to clipboard
Copied
Yep communication is *hard*. Maybe it would help if you explained your desired workflow. From what I understand so far you are just trying to cut two key combos (copy and paste-in-front) down to one. Is that right? But you have a working script already so I'm confused. If we are missing the point please let us know.
- Mark
Copy link to clipboard
Copied
ok no worries, what are you after then?
you're not wrong, Illustrator does lack in some areas, just keep in mind that not everything available in the user interface can be scripted. And don't worry about your script being 2 lines or 100 lines.
Copy link to clipboard
Copied
[EDIT]
[ script removed as it is not relevant to illustrator ]
[ post again if you have an actual Illustrator Scripting question ]

