【问题标题】:Photoshop CS4 Script or Action to: Write 0 to 100 on separate text layersPhotoshop CS4 脚本或动作:在单独的文本图层上写入 0 到 100
【发布时间】:2014-03-14 23:35:35
【问题描述】:

我的目标是创建 101 个单独的文本层,包含 0-100(即 1、2、3...100)我知道我可以批量更改属性但不能写入或更改包含的文本。

【问题讨论】:

    标签: action photoshop-script photoshop-cs4


    【解决方案1】:

    您可以使用脚本轻松完成您想要的事情(比以正确的顺序重命名 100 层并为其记录动作更容易)此脚本将创建 100 层文本,每个层将命名为 1,2,3 ..etc 和文本将是相同的。我认为这就是你所追求的,你的描述相当简短。

    // call the source document
    var srcDoc = app.activeDocument;
    var numOfLayers = 100;
    //var numOfLayers = srcDoc.layers.length; 
    var numPadding = "0";
    var layerNum = 1; // change this to 0 to start layers at 0
    var w = Math.floor(srcDoc.width.value/2);
    var h = Math.floor(srcDoc.height.value/2);
    
    
    // main loop starts here
    for (var i = numOfLayers -1; i >= 0  ; i--)
    {
    
        if (layerNum < 10) numPadding = "0";
        else numPadding ="";
        createText("Arial-BoldMT", 20.0, 0,0,0, layerNum, w, h);
        var currentLayer = srcDoc.activeLayer;
        currentLayer.name = numPadding + layerNum;
        layerNum +=1;
    }
    
    // function CREATE TEXT(typeface, size, R, G, B, content, Xpos, Ypos)
    // --------------------------------------------------------
    function createText(fface, size, colR, colG, colB, content, tX, tY)
    {
    
      var artLayerRef = srcDoc.artLayers.add()
      artLayerRef.kind = LayerKind.TEXT
      textColor = new SolidColor();
      textColor.rgb.red = colR;
      textColor.rgb.green = colG;
      textColor.rgb.blue = colB;
      textItemRef = artLayerRef.textItem
      textItemRef.font = fface;
      textItemRef.contents = content;
      textItemRef.color = textColor;
      textItemRef.size = size
      textItemRef.position = new Array(tX, tY) //pixels from the left, pixels from the top
    
      activeDocument.activeLayer.textItem.justification.CENTER
    }
    

    将其保存为 numberLayers1-100.jsx,然后通过文件 -> 脚本菜单从 Photoshop 重新运行它。

    【讨论】:

      猜你喜欢
      • 2017-10-05
      • 2013-01-12
      • 1970-01-01
      • 2011-08-13
      • 2021-07-22
      • 2020-12-15
      • 2018-11-07
      • 2020-06-03
      • 2015-06-14
      相关资源
      最近更新 更多