示例:对话框快速概述 (DCL) 
此示例说明如何使用 AutoLISP 创建基本对话框并显示该对话框。 创建 DCL 文件此 DCL 定义一个标记为“示例对话框”的对话框,其中包含一个文本磁贴和一个“确定”按钮。DCL 驻留在名为 hello.dcl 的文件中。 ![]() hello : dialog
{
  label = "Sample Dialog Box";
  : text {
    label = "Hello, world.";
  }
  ok_only;
}
 
		
 显示对话框并响应用户按 OK(defun C:HELLO ( / dcl_id )
  (setq dcl_id (load_dialog "hello.dcl")) ; Load the DCL file.
  (if (not (new_dialog "hello" dcl_id))   ; Initialize the dialog.
    (exit)                                ; Exit if this does not work.
  )
  (start_dialog)                          ; Display the dialog box.
  (unload_dialog dcl_id)                  ; Unload the DCL file.
 (princ)
)
 
		
 下面逐行解释 AutoLISP 程序的作用: 
 请注意,在用户选择其关联的操作表达式调用的磁贴(通常是按钮)之前,调用将保持活动状态。可以由磁贴显式发出调用。如果所选磁贴的属性设置为 ,则该调用也会由所选磁贴发出。start_dialogdone_dialogdone_dialogdone_dialogis_canceltrue 谨慎:从理论上讲,对话框工具在您调用时控制输入,但操作系统在您调用时控制。这对编写程序没有影响。但是,如果以交互方式调用这些函数(在 AutoCAD 命令提示符下),则必须将它们作为一个语句输入。将它们包含在一个或另一个函数中。否则,交互式调用可能会冻结屏幕。在调试期间,调用和交互式功能非常有用。start_dialognew_dialogprognnew_dialognew_dialogstart_dialog 
 
	 相关概念 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 23:26
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.