【问题标题】:Adobe Illustrator - Scripting crashes when trying to fit to artboards commandAdobe Illustrator - 尝试适应画板命令时脚本崩溃
【发布时间】:2012-07-14 21:49:36
【问题描述】:
activeDocument.fitArtboardToSelectedArt()

调用此命令时,AI 在 AI 5.1/6 32bit 和 64bit 版本上崩溃。我可以使用菜单中的命令。有没有人遇到过这个?有人知道解决方法吗?

完整代码。

    function exportFileToJPEG (dest) {
    if ( app.documents.length > 0 ) {

        activeDocument.selectObjectsOnActiveArtboard()
        activeDocument.fitArtboardToSelectedArt()//crashes here
        activeDocument.rearrangeArtboards()

        var exportOptions = new ExportOptionsJPEG();
        var type = ExportType.JPEG;
        var fileSpec = new File(dest);
        exportOptions.antiAliasing = true;
        exportOptions.qualitySetting = 70;
        app.activeDocument.exportFile( fileSpec, type, exportOptions );
    }
}
var file_name = 'some eps file.eps'
var eps_file = File(file_name)


var fileRef = eps_file;



if (fileRef != null) {
    var optRef = new OpenOptions();
    optRef.updateLegacyText = true;
    var docRef = open(fileRef, DocumentColorSpace.RGB, optRef);
}

exportFileToJPEG ("output_file.jpg")

【问题讨论】:

    标签: adobe-illustrator extendscript


    【解决方案1】:

    我可以用 AI CS5 重现这个错误。

    fitArtboardToSelectedArt() 似乎将画板的索引作为可选参数。设置参数后,Illustrator 不会崩溃。 (可能是代码处理不传参情况的bug)

    作为一种解决方法,您可以使用:

    activeDocument.fitArtboardToSelectedArt(
                   activeDocument.artboards.getActiveArtboardIndex()
                                           );
    

    将活动画板的索引传递给函数。希望这对你也有用。

    另外,最好不要在语句末尾省略分号。

    【讨论】:

    • 这仍然是 Illustrator CC 2017(版本 22.0.1)中的“问题”。文档(对象模型查看器)仍然指出画板索引是一个可选参数,但 Illustrator 在省略它时不可避免地会崩溃。感谢这个解决方案,@Jonas!
    猜你喜欢
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-20
    • 2021-10-23
    • 1970-01-01
    相关资源
    最近更新 更多