【发布时间】:2014-03-14 23:35:35
【问题描述】:
我的目标是创建 101 个单独的文本层,包含 0-100(即 1、2、3...100)我知道我可以批量更改属性但不能写入或更改包含的文本。
【问题讨论】:
标签: action photoshop-script photoshop-cs4
我的目标是创建 101 个单独的文本层,包含 0-100(即 1、2、3...100)我知道我可以批量更改属性但不能写入或更改包含的文本。
【问题讨论】:
标签: action photoshop-script photoshop-cs4
您可以使用脚本轻松完成您想要的事情(比以正确的顺序重命名 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 重新运行它。
【讨论】: