Сценарий работает, однако 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();
}