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

Collect objects from different files to one

Explorer ,
Nov 22, 2020 Nov 22, 2020

Hi guys

I need the script to collect objects from different files to one

1.I have a folder with Ai* files whicj namedlike 1,2,3,4...

2. Ineed to copy сontent from each files to one document to different layers whicn named like 1.2.3.4.5. or something like this.

It will be enough if script execute command "select all" - "copy"- "Paste" . The main goal is collect objects from different files to one.

And one small detail. I do not know Java.
I have small budget if needed.

TOPICS
Scripting
545
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
Guide ,
Nov 22, 2020 Nov 22, 2020
// "copy-n-paste" pageItems
// from open docs named 1, 2, 3, ... , n
// to corresponding layers in new untitled doc
var docs = app.documents;
var docNames = [];
for (var i = 0; i < docs.length; i++) {
  docNames.push(docs[i].name);
  docNames.sort();
}
var targetDoc = app.documents.add();
for (var i = docNames.length - 1; i > -1; i--) {
  docs[docNames[i]].activate();
  var layer1 = targetDoc.layers.add();
  layer1.name = docNames[i];
  for (var j = 0; j < app.activeDocument.pageItems.length; j ++) {
    app.activeDocument.pageItems[j].duplicate(targetDoc.layers[docNames[i]]);
  }
}
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 ,
Nov 22, 2020 Nov 22, 2020

It is good. Thank you a lot.

But I have some trouble with copied some objects. Please check my screenshots.

The first is my source file. The second is file after processing by script.

All select layers are copies.

 

P.S. I think it is my trouble and I should give your more information about files?

 

Be_Illustrator_0-1606020296405.pngexpand image

Be_Illustrator_1-1606020316973.pngexpand image

 

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 ,
Nov 22, 2020 Nov 22, 2020

Sorry. It really works with more clearly files

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 ,
Nov 22, 2020 Nov 22, 2020

Thanks. You've made my day

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
Guide ,
Nov 22, 2020 Nov 22, 2020

👍

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 ,
Nov 22, 2020 Nov 22, 2020

could it work for "Group" objects?

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
Guide ,
Nov 23, 2020 Nov 23, 2020
LATEST

@Berezin_Illustrator  There was an oversight in the above script.  It copied all pageItems, so it copied groups and separately copied paths within groups, i.e. it copyed grouped-paths twice.  (The same with compound paths.)  This should rectify that:

// "copy-n-paste" pageItems
// from open docs named 1, 2, 3, ... , n
// to corresponding layers in new untitled doc
var docs = app.documents;
var docNames = [];
for (var i = 0; i < docs.length; i++) {
  docNames.push(docs[i].name);
  docNames.sort();
}
var targetDoc = app.documents.add();
for (var i = docNames.length - 1; i > -1; i--) {
  docs[docNames[i]].activate();
  var layer1 = targetDoc.layers.add();
  layer1.name = docNames[i];
  label: for (var j = 0; j < app.activeDocument.pageItems.length; j ++) {
    var item = app.activeDocument.pageItems[j];
    if (item.parent.typename == "GroupItem" || 
        item.parent.typename == "CompoundPathItem") {
      continue label;
    }
    item.duplicate(targetDoc.layers[docNames[i]]);
  }
}

 

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