illustrator插件--常用功能开发--标注纵尺寸--js脚本开发--AI插件

该博客介绍了一段用于Illustrator的脚本代码,该代码能够自动化标注图形的纵尺寸,特别是在印刷领域的应用。通过这段代码,设计师可以快速地为选择的图形添加尺寸标注,提高工作效率,减少了手动操作的繁琐步骤。脚本根据图形大小调整标注的字体大小,并使用红色CMYK颜色进行高对比度显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  illustrator是矢量编辑软件,画板是绘制处理的重要容器,在印刷方面的一个重要功能就是标注纵尺寸,开发一个标注纵尺寸功能,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:


doc = app.activeDocument;
theSelect = doc.selection;
for (var i = 0; i < theSelect.length; i += 1) {
    x = theSelect[i].left;
    y = theSelect[i].top;
    w = theSelect[i].width;
    h = theSelect[i].height;
    s = 30;
    asize = 20;
    if (h < 50 || w < 50) {
        asize = 5;
    }
    tsize = 36;
    if (h < 60 || w < 60) {
        tsize = 12;
    }
    redColor = new CMYKColor();
    redColor.black = 1;
    redColor.cyan = 1;
    redColor.magenta = 100;
    redColor.yellow = 100;
    var g1 = doc.groupItems.add();
    var line1 = g1.pathItems.add();
    line1.setEntirePath(new Array(new Array(x - s, y), new Array(x - s, y - h)));
    line1.strokeColor = redColor;
    var line1 = g1.pathItems.add();
    line1.setEntirePath(new Array(new Array((x - s) - (s / 2), y), new Array(x - (s / 2), y)));
    line1.strokeColor = redColor;
    var line1 = g1.pathItems.add();
    line1.setEntirePath(new Array(new Array((x - s) - (s / 2), y - h), new Array(x - (s / 2), y - h)));
    line1.strokeColor = redColor;
    var ar1 = g1.pathItems.add();
    ar1.setEntirePath(new Array(new Array(x - s, y), new Array((x - s) - (asize / 2), y - asize), new Array((x - s) + (asize / 2), y - asize)));
    ar1.strokeColor = NoColor;
    ar1.fillColor = redColor;
    ar1.closed = true;
    var ar1 = g1.pathItems.add();
    ar1.setEntirePath(new Array(new Array(x - s, y - h), new Array((x - s) - (asize / 2), (y - h) + asize), new Array((x - s) + (asize / 2), (y - h) + asize)));
    ar1.strokeColor = NoColor;
    ar1.fillColor = redColor;
    ar1.closed = true;
    var t1 = g1.textFrames.add();
    t1.contents = (Math.round(h * 0.35277778 * 1000) / 1000) + " mm";
    t1.textRange.characterAttributes.size = tsize;
    t1.textRange.characterAttributes.fillColor = redColor;
    t1.left = ((x - s) - s) - (t1.width / 2);
    t1.top = (y - (h / 2)) + (t1.height / 2);
    t1.rotate(90);
}


  合理的脚本代码可以有效的提高工作效率,减少重复劳动。

文章引用至 作者知了-联系方式1
文章引用至 作者知了-联系方式2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值