Nic*_*lis 2 extendscript adobe-illustrator
activeDocument.fitArtboardToSelectedArt()
Run Code Online (Sandbox Code Playgroud)
调用此命令时,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")
Run Code Online (Sandbox Code Playgroud)
我可以用 AI CS5 重现这个错误。
似乎fitArtboardToSelectedArt()将画板的索引作为可选参数。设置参数后,Illustrator 不会崩溃。(可能是代码中处理无参数传递情况的一个bug)
作为一种解决方法,您可以使用:
activeDocument.fitArtboardToSelectedArt(
activeDocument.artboards.getActiveArtboardIndex()
);
Run Code Online (Sandbox Code Playgroud)
将活动画板的索引传递给函数。希望这对你也有用。
此外,永远不要省略语句末尾的分号,这是一种很好的做法。
| 归档时间: |
|
| 查看次数: |
1337 次 |
| 最近记录: |