Illustrator脚本document.close()方法崩溃

时间:2017-07-30 17:50:17

标签: scripting adobe-illustrator

在Illustrator CS6中,我想将所有选择导出到每个SVG文件。 我的序列是这样的。

  1. 使用documents.addDocument()方法
  2. 创建临时文档
  3. i个选项复制到临时文档。
  4. 使用document.exportFile()方法导出为SVG文件。
  5. 使用document.close()方法关闭临时文档。
  6. 但是当到达序列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
    }
    

    *导出目录存在且为空。

1 个答案:

答案 0 :(得分:0)

我刚刚在Illustrator CC 2017中运行您的代码,它运行正常。可能是旧版本的Illustrator有一些问题。为什么不切换到最新版本的Illustrator?现在我没有CS6,但我也会尝试使用CS6并让你知道。