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

Paste in place script

Engaged ,
Oct 25, 2022 Oct 25, 2022

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.

TOPICS
Scripting
1.7K
Translate
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
Adobe
Community Expert ,
Oct 25, 2022 Oct 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?

Translate
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
Engaged ,
Oct 25, 2022 Oct 25, 2022

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

 

Translate
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
Community Expert ,
Oct 25, 2022 Oct 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;
}
Translate
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
Community Expert ,
Oct 25, 2022 Oct 25, 2022

I would go with this then. There's nothing wrong with using Menu Commands

app.executeMenuCommand("copy");
app.executeMenuCommand("pasteInPlace");

 

Translate
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
Community Expert ,
Oct 25, 2022 Oct 25, 2022

Succinct and to the point! 🙂

Translate
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
Community Expert ,
Oct 25, 2022 Oct 25, 2022

right?!

 

(we might be missing something though)

Translate
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
Engaged ,
Oct 26, 2022 Oct 26, 2022

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. 

Translate
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
Community Expert ,
Oct 26, 2022 Oct 26, 2022

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

Translate
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
Community Expert ,
Oct 26, 2022 Oct 26, 2022

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.

Translate
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
New Here ,
Mar 30, 2024 Mar 30, 2024
LATEST

[EDIT]

[ script removed as it is not relevant to illustrator ]

 

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

 

Translate
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