该脚本有效,但是在通过色板颜色进行导出之前,插画家会将笔划大小重置为默认值。有谁知道为什么以及如何解决此问题?
#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();
}