尝试创建illustrator脚本以填充所选内容的颜色并为色板组中的每种颜色导出它

正如标题所述,我拼凑而成并将自己的代码编写到您在下面看到的这种怪异中。自完成任何编码以来已经过去三年了,我的主要工作是图形设计,所以请原谅草率的编码工作。我要完成的工作是让脚本在色板中运行,并将填充颜色应用于屏幕上选定的颜色,然后为每种颜色导出一个.png文件,并将文件名作为色板的颜色。

似乎所有脚本都可以使用,除了它不应用填充颜色。它将为色板组中的每种颜色导出甚至重命名文件,但是它们都导出相同的默认颜色,因此我不相信所选内容正在被填充。谁能指导我代码中的错误?如果我可以使该代码正常工作,它将把不合理的工作量转变为更易于管理的工作。

谢谢!

#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 fill colour based on the current swatch colour

   mySelection.fillColor = 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();
}
angeldou123 回答:尝试创建illustrator脚本以填充所选内容的颜色并为色板组中的每种颜色导出它

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3164412.html

大家都在问