您当前的位置: 首页 > 

插件开发

暂无认证

  • 3浏览

    0关注

    492博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

illustrator插件-常用功能开发-创建参考线-js脚本开发

插件开发 发布时间:2022-03-13 07:13:41 ,浏览量:3

文章目录
    • 1.算法程序
    • 2.作者答疑

1.算法程序

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

var nSel = app.selection.length;
if (nSel > 0) {
    doWindow();
} else {
    alert("选择对象以创建参考线标记");
}

function doWindow() {
    var win = new Window("dialog", "创建参考线", [150, 150, 666, 550]);
    win.edgesPanel = win.add("panel", [25, 20, 290, 100], "方位");
    win.one4allPanel = win.add("panel", [25, 120, 290, 180], "类别");
    win.visgeoPanel = win.add("panel", [25, 200, 290, 260], "边界");
    win.offsetPanel = win.add("panel", [25, 280, 290, 355], "位移");
    win.edgesPanel.chkTop = win.edgesPanel.add("checkbox", [16, 10, 80, 30], "上");
    win.edgesPanel.chkBottom = win.edgesPanel.add("checkbox", [62, 10, 180, 30], "下");
    win.edgesPanel.chkLeft = win.edgesPanel.add("checkbox", [149, 10, 220, 30], "左");
    win.edgesPanel.chkRight = win.edgesPanel.add("checkbox", [206, 10, 280, 30], "右");
    win.edgesPanel.chkCntrHor = win.edgesPanel.add("checkbox", [16, 40, 120, 60], "纵向中心");
    win.edgesPanel.chkCntrVert = win.edgesPanel.add("checkbox", [149, 40, 300, 60], "横向中心");
    win.edgesPanel.chkTop.value = true;
    win.edgesPanel.chkBottom.value = true;
    win.edgesPanel.chkLeft.value = true;
    win.edgesPanel.chkRight.value = true;
    win.edgesPanel.chkCntrHor.value = true;
    win.edgesPanel.chkCntrVert.value = true;
    win.one4allPanel.each = win.one4allPanel.add("radiobutton", [16, 10, 150, 34], "逐个对象");
    win.one4allPanel.all = win.one4allPanel.add("radiobutton", [149, 10, 280, 34], "视为整体");
    win.one4allPanel.each.value = true;
    win.visgeoPanel.vis = win.visgeoPanel.add("radiobutton", [16, 10, 150, 34], "视觉边界");
    win.visgeoPanel.geo = win.visgeoPanel.add("radiobutton", [149, 10, 280, 34], "轮廓边界");
    win.visgeoPanel.geo.value = true;
    win.offsetPanel.vOffLbl = win.offsetPanel.add("statictext", [16, 10, 100, 30], " 纵向");
    win.offsetPanel.vOff = win.offsetPanel.add("edittext", [68, 8, 118, 28], "0");
    win.offsetPanel.vOffLbl = win.offsetPanel.add("statictext", [125, 10, 147, 30], "mm ");
    win.offsetPanel.hOffLbl = win.offsetPanel.add("statictext", [16, 40, 100, 60], " 横向");
    win.offsetPanel.hOff = win.offsetPanel.add("edittext", [68, 38, 118, 58], "0");
    win.offsetPanel.hOffLbl = win.offsetPanel.add("statictext", [125, 40, 147, 60], "mm ");
    win.cancelBtn = win.add("button", [120, 370, 198, 390], "取消");
    win.quitBtn = win.add("button", [213, 370, 291, 390], "确定");
    win.defaultElement = win.quitBtn;
    win.cancelElement = win.cancelBtn;
    win.quitBtn.onClick = function() {
        var bVB = win.visgeoPanel.vis.value;
        var bEach = win.one4allPanel.each.value;
        var xOff = win.offsetPanel.hOff.text.replace(",", ".");
        var yOff = win.offsetPanel.vOff.text.replace(",", ".");
        if (yOff.search("pt") > 0) {
            yOff = yOff.replace("pt", "");
            yOff = yOff * 1;
        } else {
            yOff = (yOff * 72) / 25.4;
        }
        if (xOff.search("pt") > 0) {
            xOff = xOff.replace("pt", "");
            xOff = xOff * 1;
        } else {
            xOff = (xOff * 72) / 25.4;
        }
        var bTop = win.edgesPanel.chkTop.value;
        var bLeft = win.edgesPanel.chkLeft.value;
        var bRight = win.edgesPanel.chkRight.value;
        var bBottom = win.edgesPanel.chkBottom.value;
        var bVC = win.edgesPanel.chkCntrVert.value;
        var bHC = win.edgesPanel.chkCntrHor.value;
        win.close();
        doGuides(bTop, bLeft, bBottom, bRight, bVC, bHC, bVB, bEach, xOff, yOff);
    };
    win.center();
    win.show();
}

function doGuides(bTop, bLeft, bBottom, bRight, bVC, bHC, bVB, bEach, xOff, yOff) {
    if (bEach == true) {
        for (var n = 0; n             
关注
打赏
1665481431
查看更多评论
0.0392s