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();
}
ituyuan 回答:Illustrator脚本有问题,无法为线条的笔迹着色,然后将其以色板组中的所有颜色导出

您的脚本将笔触大小重置为默认值,因为在循环的第一轮中,笔触颜色被设置为“ (x0,y0,z0)”。

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

例如;您需要将当前脚本中的[None]循环部分改为以下内容:

for

注意:在运行脚本之前,您需要确保在ArtBoard文档中至少有一个选定的项目。

本文链接:https://www.f2er.com/3158644.html

大家都在问