改变矢量形状的颜色 - photoshop

时间:2016-06-17 21:17:07

标签: javascript photoshop jsx

我的代码有问题,它会改变矢量形状的颜色。

它仅适用于一个图层,如果您选择更多图层,则会弹出错误。有谁知道如何解决它?

#target photoshop
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function Action3() {

  function step1(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(sTID("contentLayer"), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    var desc3 = new ActionDescriptor();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(cTID('Rd  '), 243);
    desc4.putDouble(cTID('Grn '), 110);
    desc4.putDouble(cTID('Bl  '), 93);
    desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);
    desc2.putObject(cTID('FlCn'), sTID("solidColorLayer"), desc3);
    var desc5 = new ActionDescriptor();
    desc5.putInteger(sTID("strokeStyleVersion"), 2);
    desc5.putBoolean(sTID("fillEnabled"), true);
    desc2.putObject(sTID("strokeStyle"), sTID("strokeStyle"), desc5);
    desc1.putObject(cTID('T   '), sTID("shapeStyle"), desc2);
    executeAction(cTID('setd'), desc1, dialogMode);

  };

  step1();      // Set
};

Action3.main = function () { Action3();};Action3.main();

1 个答案:

答案 0 :(得分:0)

您应该取消选择不是形状图层的所有图层。或者逐个更改图层。 (这就是为什么在更改颜色时CC库如此慢的原因)。如果我有多个形状图层,您的代码适合我,但所有选定的图层必须是形状而不是其他任何形状。无论如何,Photoshop中存在一个错误,如果图层中的一个没有中风,可以从所有选定的图层中删除笔划选项。