【问题标题】:Looping through text items an illustrator page循环浏览插图页面的文本项
【发布时间】: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


    【解决方案1】:

    解决这个问题的方法是反转循环。基本上,当您将项目移动到一个组中时,它会更改页面上“松散”文本项目的数量,因此您的循环长度会在中途有效地改变。可以在https://forums.adobe.com/thread/2171307 找到对此的良好视觉解释,我也在其中发布了问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-10
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多