Javascript Illustrator脚本对线条的笔划着色,然后将其导出为样例组中的所有颜色时出现问题

Javascript Illustrator脚本对线条的笔划着色,然后将其导出为样例组中的所有颜色时出现问题,javascript,scripting,adobe,adobe-illustrator,extendscript,Javascript,Scripting,Adobe,Adobe Illustrator,Extendscript,脚本可以工作,但是illustrator会在查看样例颜色并导出之前将笔划大小重置为默认值。有人知道为什么以及如何解决这个问题吗 #target illustrator //get a reference to the the current document var doc = app.activeDocument; var mySelection = doc.selection; var swatches = doc.swatches; //select a folder to save

脚本可以工作,但是illustrator会在查看样例颜色并导出之前将笔划大小重置为默认值。有人知道为什么以及如何解决这个问题吗

#target illustrator

//get a reference to the the current document

var doc = app.activeDocument;
var mySelection = doc.selection;
var swatches = doc.swatches;

//select a folder to save images into
var savePath = Folder.selectDialog( 'Please select a folder to export swatch images into', '~' );
//exported image dimensions
var width = 100;
var height = 100;
//PNG export options
var pngExportOpts = new ExportOptionsPNG24();
   pngExportOpts.antiAliasing = false;//keep it pixel perfect 
   pngExportOpts.artBoardClipping = false;//use the path's dimensions (setup above), ignore full document size
   pngExportOpts.saveAsHTML = false;
   pngExportOpts.transparency = true;//some swatches might have transparency


//go through the swatches


for(var i = 0; i < swatches.length; i++){
   //set the stroke colour based on the current swatch colour

   for(var j=0; j<mySelection.length; j++) { mySelection[j].strokeColor = swatches[i].color; }

   //export png
   doc.exportFile( new File( savePath+ '/' + swatches[i].name + '.png'), ExportType.PNG24, pngExportOpts );
   //remove any previous paths (in case of transparent swatches)

   //doc.pathItems.removeAll();
}
#目标illustrator
//获取对当前文档的引用
var doc=app.activeDocument;
var mySelection=doc.selection;
var样本=doc.swatches;
//选择要将图像保存到的文件夹
var savePath=Folder.selectDialog('请选择要将样例图像导出到的文件夹','~');
//导出的图像尺寸
var宽度=100;
var高度=100;
//PNG导出选项
var pngExportOpts=新的导出选项png24();
pngExportOpts.antiAliasing=false//保持像素完美
pngExportOpts.artBoardClipping=false//使用路径的尺寸(上面的设置),忽略完整文档大小
pngExportOpts.saveAsHTML=false;
pngExportOpts.transparency=true//某些样例可能具有透明度
//检查样本
对于(变量i=0;i对于(var j=0;j您的脚本正在将笔划大小重置为默认值,因为在循环的第一个回合中,笔划颜色被设置为“
[None]

仅当当前样例未命名为“
[None]
”时,才尝试更改笔划颜色

例如,您需要将当前脚本中
循环部分的
更改为以下内容:

/。。。
//检查样本
对于(变量i=0;i
注意:在运行脚本之前,您需要确保文档艺术板上至少有一个选定项目