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

app.copy(); app.paste(); doesn't work perfectly.

Explorer ,
Aug 24, 2023 Aug 24, 2023
What could be causing app.copy(); app.paste(); to not work perfectly in the script below?
The R-letter is missing when copying and pasting.
It works fine when I copy and paste in the app and not in the script.
 
function load(url) {
    var loadFile;
    loadFile = new File(url);
    doc = app.open(loadFile);
    doc.rulerOrigin = [0, 0];
}
load("C:/podContents/illustrator_error/tshirt0.ai");
var layer = doc.layers[0];
var gItem = layer.groupItems[0];
doc.selection = gItem;
app.copy();
app.paste();
 
 
2002854_0-1692864519359.png

 

 
TOPICS
Scripting
413
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
Explorer ,
Aug 24, 2023 Aug 24, 2023

The reason we need copy and paste is because we want to copy from the original file and then open another document to paste it into.

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
Explorer ,
Aug 24, 2023 Aug 24, 2023

I solved it.

 

function load(url) {
    var loadFile;
    loadFile = new File(url);
    doc = app.open(loadFile);
    doc.rulerOrigin = [0, 0];
}

load("C:/podContents/illustrator_error/tshirt0.ai");

var layer = doc.layers[0];
var gItem = layer.groupItems[0];
doc.selection = gItem;

var emptyDoc = app.documents.add(DocumentColorSpace.RGB, 714.8721 , 1716.4345 );
var copied = gItem.duplicate(emptyDoc);
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 ,
Aug 24, 2023 Aug 24, 2023
LATEST

Nice! Well done. 

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 ,
Aug 24, 2023 Aug 24, 2023

Hi @은정주2002854, sorry I don't know why the R isn't being copy/pasted. However, I would recommend if you can use PageItem.duplicate() instead. This is a better options because it doesn't need to disturb the clipboard.

- Mark

 

var dup = gItem.duplicate(myLayerInOtherDocument, ElementPlacement.INSIDE);
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
Explorer ,
Aug 24, 2023 Aug 24, 2023

Thank you for your reply.

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