我正在尝试为 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/