我有大约 200 个 SVG 文件,需要将其描边颜色更改为灰色,并将所有线条的描边宽度更改为 0.2pt。
我想编写与界面中的操作等效的脚本 - “选择全部”,然后手动输入 0.2 pt 的笔划宽度。
现在,我的脚本正在将所有颜色更改为灰色(工作正常),并将某些线条的描边宽度更改为 0.2pt。
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var doc = app.activeDocument;
for ( i = 0; i <doc.pathItems.length; i++ ) {
pathArt = doc.pathItems[i];
pathArt.strokeWidth = .2;
pathArt.strokeColor = makeColor(153,153,153);
pathArt.filled = false;
}
function makeColor(r,g,b){
var c = new RGBColor();
c.red = r;
c.green = g;
c.blue = b;
return c;
}
也许我没有通过脚本正确选择所有对象? 像我上面所做的那样选择路径项目是实现相当于 CTRL-A 然后手动进行一些操作的正确方法吗?
非常感谢您的宝贵时间!
最佳答案
从 AI CS3 开始,当路径未进行描边时,.StrokeColor
属性适用,而 .StrokeWidth
属性则不适用。
添加代码pathArt.Stroked = True;
来解决您的问题
另请注意,您不会迭代 CompoundPathItems
关于Javascript Adobe Illustrator 脚本 - 更改所有项目的笔划宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44790145/