2017-07-30 39 views
0

在Illustrator CS6中,我想將所有選擇導出到每個SVG文件。 我的順序是這樣的。Illustrator腳本document.close()方法崩潰

  1. 進行臨時文件,使用documents.addDocument()方法
  2. 複製i日選擇臨時文件。
  3. 使用document.exportFile()方法導出爲SVG文件。
  4. 使用document.close()方法關閉臨時文檔。

但是,當到達序列4時,Illustrator崩潰。 問題是什麼?

var sel = activeDocument.selection; 

var arr = new Array; 
for(var i=0;i<sel.length;i++) 
{ 
    arr.push(sel[i]); 
} 

var preset = new DocumentPreset; 
var option = new ExportOptionsSVG; 
option.compressed = false; 
option.fontType = SVGFontType.OUTLINEFONT; 

for(var i=0;i<arr.length;i++) 
{ 
    doc = app.documents.addDocument(i,preset); //sequence 1 
    var item = arr[i].duplicate();   //sequence 2 
    item.move(doc,ElementPlacement.PLACEATEND); 

    expFile = new File("C:\\Users\\user\\Documents\\font project\\svg\\" + i); 

    doc.exportFile(expFile,ExportType.SVG,option); //sequence 3 

    doc.close(); //sequence 4 and it occurs crashes 
} 

*導出目錄存在,它是空的。

回答

0

我剛剛在Illustrator CC 2017中運行代碼,它工作正常。可能在舊版本的Illustrator中有一些問題。爲什麼不切換到最新版本的Illustrator?現在我沒有CS6,但我也會嘗試CS6,並讓你知道。