javascript - 如何为 Illustrator CS5 的嵌套复合路径 Extendscript 着色?

标签 javascript adobe-illustrator extendscript

我正在尝试为 Illustrator 中的 compoundPathItem 内的 pathItems 着色。我的对象看起来像一个圆套着一个圆。没有笔划,四个路径,compoundPathItem 内有两个 compoundPathItems

当我使用此行进行调试时:alert(doc.compoundPathItems[0])我得到:-[CompoundPathItem] ....这是有道理的,因为我组合了两个compoundPathItems。

但是,我似乎无法访问 pathItems 来为它们着色:

doc.compoundPathItems[0].compoundPathItems[0].pathItems ... errors out x_x ... 
alert(doc.compoundPathItems[0].pathItems.length) gives me 0 .... T-T

请帮我理解这里发生了什么。

最佳答案

如果所有pageItems都是compoundItems,则此脚本将起作用,app.activeDocument.pathItems将给出所有pathItems在文件中。它还将嵌套在compoundPathItem 中。所以尝试一下它是否适合你

var currentDocument = app.activeDocument;
var pathItems = currentDocument.pathItems;
var redSwatch = currentDocument.swatches.getByName('CMYK Red');
var blueSwatch = currentDocument.swatches.getByName('CMYK Blue');
for (var i = 0; i < pathItems.length; i++) {
    pathItems[i].filled = true;
    pathItems[i].fillColor = redSwatch.color;
    pathItems[i].stroked = true;
    pathItems[i].strokeColor = blueSwatch.color;
}

关于javascript - 如何为 Illustrator CS5 的嵌套复合路径 Extendscript 着色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26762746/

相关文章:

adobe-illustrator - 更改 EMF 图像文件的分辨率以防止 PowerPoint 中的质量损失

javascript - 不要将 Indesign 标签添加到根元素?

javascript - JavaScript 中的命名空间技术在 JSLint 中存在问题

javascript - 图像预加载后执行 JavaSCript 代码

c# - .NET 调整大小的图像无法在 Adob​​e 软件中打开

javascript - 如何使用 Adob​​e Illustrator 脚本编写画板?

adobe-illustrator - File.execute() 没有执行我的脚本。如何调试这个问题?

javascript - Photoshop Javascript 获取选定的路径项目?

javascript - 单击屏幕上的任意位置时,jQuery 隐藏 Bootstrap 幻灯片菜单

javascript - 使用semantic-ui-calendar 设置 minDate 和 maxDate