【发布时间】:2016-06-22 17:02:43
【问题描述】:
我有一个 Illustrator 文档,上面有各种文本和路径项。我想遍历所有文本项并更改它们的颜色以及几个属性。然后根据项目名称,我想将其与其他同名项目分组。我有一个几乎可以工作的脚本。问题是它遗漏了一些项目,或者不一致地忽略它们。有时它会影响它们,有时它只是忽略它们。任何帮助表示赞赏,下面的脚本
//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);
};
};
【问题讨论】:
标签: adobe-illustrator extendscript