CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoLISP 开发指南

使用 DCL 定义对话框

2023-1-5 08:00| 发布者: admin| 查看: 470| 评论: 0|来自: AutoCAD

首先查看需要创建的对话框。

该对话框包含以下元素:

  • 两组单选按钮。

    一组按钮确定边界的折线样式,另一组按钮指定磁贴实体创建方法 (ActiveX、或)。一次只能选择集中的一个单选按钮。entmakecommand

  • 用于指定切片半径和切片间距的编辑框。
  • 一组标准的“确定”和“取消”按钮。

对话框组件在 DCL 中称为磁贴。编写对话框 DCL 文件的完整内容可能看起来势不可挡。诀窍是勾勒出你想要的东西,将其分解成几个部分,然后写下每个部分。

定义对话框

  1. 在 Visual LISP 文本编辑器窗口中打开一个新文件。
  2. 在新文件中输入以下语句:
    label = "Garden Path Tile Specifications";

    此 DCL 语句定义对话框窗口的标题。

  3. 通过添加以下代码定义用于指定折线类型的单选按钮:
    : boxed_radio_column {    // defines the radio button areas
      label = "Outline Polyline Type";
      : radio_button {        // defines the lightweight radio button
        label = "&Lightweight";
        key = "gp_lw";
        value = "1";
       }
    : radio_button {       // defines the old-style polyline radio button
      label = "&Old-style";
      key = "gp_hw";
     }
    }

    DCL 指令定义框边界,并允许您为按钮集指定标签。在边界内,您可以通过添加指令来指定所需的单选按钮。每个单选按钮都需要一个标签和一个。键是 AutoLISP 代码可以引用按钮的名称。boxed_radio_columnradio_button

    请注意,标记为“轻量级”的单选按钮的值为 1。分配给按钮的值 1(字符串,而不是整数)使其成为按钮行中的默认选项。换句话说,当您第一次显示对话框时,将选择此按钮。另请注意,在 DCL 文件中,双斜杠字符(而不是 AutoLISP 中的分号)表示注释。

  4. 通过添加以下代码定义用于选择实体创建样式的单选列:
    : boxed_radio_column {     // defines the radio button areas
      label = "Tile Creation Method";
      : radio_button {         // defines the ActiveX radio button
        label = "&ActiveX Automation";
        key = "gp_actx";
        value = "1";
       }
    : radio_button {          // defines the (entmake) radio button
      label = "&Entmake";
      key = "gp_emake";
     }
    : radio_button {          // defines the (command) radio button
      label = "&Command";
      key = "gp_cmd";
     }
    }
  5. 添加以下代码以定义允许用户输入指定磁贴大小和间距的数字的编辑框磁贴:
    : edit_box {      // defines the Radius of Tile edit box
      label = "&Radius of tile";
      key = "gp_trad";
      edit_width = 6;
    }
    : edit_box {      // defines the Spacing Between Tiles edit box
      label = "S&pacing between tiles";
      key = "gp_spac";
      edit_width = 6;
    }

    请注意,此定义不会为编辑框设置任何初始值。您将为 AutoLISP 程序中的每个编辑框设置默认值。

  6. 为“确定”和“取消”按钮添加以下代码:
    : row {          // defines the OK/Cancel button row
      : spacer { width = 1; }
      : button {    // defines the OK button
        label = "OK";
        is_default = true;
        key = "accept";
        width = 8;
        fixed_width = true;
      }
      : button {    // defines the Cancel button
        label = "Cancel";
        is_cancel = true;
        key = "cancel";
        width = 8;
        fixed_width = true;
      }
      : spacer { width = 1;}
    }

    这两个按钮都在一行中定义,因此它们水平排列。

  7. 滚动到文本编辑器窗口的开头,并将以下语句作为 DCL 的第一行插入:
    gp_mainDialog : dialog {
  8. 该指令需要一个右大括号,因此滚动到文件末尾并将大括号添加为 DCL 代码的最后一行:dialog
    }

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 12:03

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部