我正在寻找将illustrator中选定对象中的特定颜色更改为另一种颜色的脚本
我发现在“图层”中对所有颜色进行很少修改的代码如何将其设置为适用于所选项目。
谢谢

        var layer = app.activeDocument.activeLayer;
    var findColor = new RGBColor()
    findColor.red = 180;
    findColor.green = 90;
    findColor.blue = 90;

    var setColor = new RGBColor()
    setColor.red = 90;
    setColor.green = 180;
    setColor.blue = 180;

    for (var i = 0; i < layer.pathItems.length; i++) {
      var item = layer.pathItems[i];

      $.writeln("find colour ",Math.round( item.fillColor.red))
        if (Math.round(item.fillColor.red) == findColor.red &&
        Math.round(item.fillColor.green)== findColor.green &&
        Math.round(item.fillColor.blue) == findColor.blue)
       {
          $.writeln("Color function",i );
          item.fillColor = setColor;
       }
}

最佳答案

希望这会有所帮助,您可以尝试一下;

var docRef = app.activeDocument;

var setColor = new RGBColor();

 setColor.red = 90;
    setColor.green = 180;
    setColor.blue = 180;


theSelect = docRef.selection;
if(theSelect.length == 0){
    alert("No selected layer detected");}
    else{
        for (i=0;i<theSelect.length;i++){
        var SlctLyr= theSelect[i]
        SlctLyr.filled = true;
        SlctLyr.fillColor = setColor;}}

09-26 04:17