Quantcast
Viewing all articles
Browse latest Browse all 12845

Solution to Script : Pasting artwork is slow, includes unused data

I have a solution about 'many swatch' problem (http://helpx.adobe.com/illustrator/kb/copy-paste-artwork-slow-or.html)

 

1. Unlock all object (Ctrl+Alt+2)

2. select All object (Ctrl+A)

3. run script

 

principle is ...

(1) open new document

(2) copy selected object to new document

(3) save new document (XXX_new.ai)

 

 

I'm not good programmer. So I feel uneasy open my source code. But, It's maybe hint for your problem.

 

If it's not work, send AI file. I need variety test data.

 

part3story@gmail.com

 

 

 

 

var title = "SWATCHmata";


var docPreset = new DocumentPreset;
          docPreset.units = RulerUnits.Millimeters;          docPreset.width = 297*2.83464566929134;          docPreset.height=210*2.83464566929134; 

if(app.documents.length == 0){alert("file open please", title)}

else {
          var runConfirm = confirm("copy selected object only. Locked object was NOT copy. keep going?", false, title);          if(runConfirm==true){                    var docRef = activeDocument;                    var newGroup = docRef.groupItems.add();                    var Sel = docRef.selection;                    if(Sel.length>0){ SWATCHmata();}                    }          }


function Ungroup(whereToUngroup, group) // where to ungroup? layer, document, other group?
     {          for (i=group.pageItems.length-1; i>=0; i--)               group.pageItems[i].move(whereToUngroup, ElementPlacement.PLACEATBEGINNING);     }


function cutEx(path){
          var fullPath = path;          var fileName = path.slice(0, path.lastIndexOf("."));          return fileName
}


function exportFileToAI (myDoc, dest) {
          if ( app.documents.length > 0 ) {                    var saveOptions = new IllustratorSaveOptions();                    var ai13Doc = new File(dest);                    saveOptions.compatibility = Compatibility.ILLUSTRATOR13;                    saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;                    myDoc.saveAs( ai13Doc, saveOptions );          }
}


function SWATCHmata(){                 var docRef2 = documents.addDocument(DocumentColorSpace.CMYK, docPreset);          for(i=0; i<Sel.length; i++){                    Sel[i].duplicate(newGroup, ElementPlacement.PLACEATEND); //copy                    }          newGroup.move(docRef2, ElementPlacement.PLACEATBEGINNING)           var myFilePath = docRef.path          var myFileName = cutEx(docRef.name) + "_new.ai";          var fullPath = myFilePath +"/" + myFileName;           exportFileToAI(docRef2, fullPath)           docRef2.selected = true;          Ungroup(docRef2, newGroup);
}

Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>