0
我有一个插图文档,其上有各种文本和路径项目。我想遍历所有的文本项目,并改变它们的颜色和几个属性。然后根据项目名称,我想将它与其他具有相同名称的项目分组。我有一个几乎可以工作的脚本。问题是它留下了一些项目,或者不一致地忽略它们。有时它会影响它们,有时它会忽略它们。理解的任何帮助,下面的脚本在文本项目中循环插画页面
//Selects the graph before to scale them and turns off the pixel align so that values of 1 decimal place can be applied to strokes
doc.selectObjectsOnActiveArtboard();
var sel = doc.selection;
sel.pixelAligned=false
var item
var xLabels = layer.groupItems.add(); //create group for xAxis
xLabels.name="xLabels"
var yLabels = layer.groupItems.add(); //create group for xAxis
yLabels.name="yLabels"
var yTicks = layer.groupItems.add(); //create group for xAxis
yTicks.name="yTicks"
//Loops through ungrouped text items and set horizontal scale, spot black and tabular lining on figures
for (var i = 0; i < layer.textFrames.length; i++) {
item=layer.textFrames[i];
$.writeln (item)
item.textRange.characterAttributes.textFont = textFonts.getByName("Metric-Regular");
item.textRange.characterAttributes.figureStyle=FigureStyleType.TABULAR
item.textRange.characterAttributes.fillColor=myBlack;
//move labels on xAxis into the same group
if (item.name=="xAxisLabel") {
item.moveToEnd(xLabels);
}
//move labels on yAxis into the same group
if (item.name=="yAxisLabel") {
item.moveToEnd(yLabels);
};
};
for (var i = 0; i < layer.pathItems.length; i++) {
item=layer.pathItems[i];
if (item.name=="yAxisTick") {
item.moveToEnd(yTicks);
};
};