获取对话框数值示例代码:read 读取数值
- ;以下为对话框程序自动生成:
- (defun ngc-dcl()
- (setq dcl_file (vl-filename-mktemp nil nil ".dcl"))
- (setq f_dcl (open dcl_file "w"))
- ;;下面的对话框名称ngc,和下面的对应,可以改成自己的名称,要上下对应:
- (write-line "ngc:dialog {" f_dcl)
- (write-line " label = \"春蝉可视化\" ;" f_dcl)
- (write-line " :edit_box {" f_dcl)
- (write-line " edit_width = 20 ;" f_dcl)
- (write-line " key = \"srsz\" ;" f_dcl)
- (write-line " label = \"圆的半径\" ;" f_dcl)
- (write-line " }" f_dcl)
- (write-line " ok_cancel;" f_dcl)
- (write-line "}" f_dcl)
- (close f_dcl)dcl_file)
- ;;主程序开始:-------------------------------
- (defun c:tt ()
- (setvar "cmdecho" 0) ;_关闭命令提示
- (setq osmode_bak (getvar "osmode")) ;_记录捕捉
- (setvar "osmode" 0) ;_关闭捕捉
- (setq dcl_id (load_dialog (setq dcl_file (ngc-dcl))));;对话框加载
- (vl-file-delete dcl_file);;加载后删除dcl文件
- (setq chk 0);;设置关键联动默认变量为0
- (new_dialog "ngc" dcl_id);;此处为对话框名称ngc,和上面对应,要上下对应
- (setq keys '("srsz" "accept" "cancel"));对话框key值列表
- (foreach key keys (if (eval (read (strcat key "_bak"))) (set_tile key (eval (read (strcat key "_bak"))))))
- (action_tile "accept" "(setq chk 1)(备份数据)(done_dialog 1)");;确定按钮动作关联
- (start_dialog)
- (读取对话框数据);;此处为读取对话框数据的地方
- (unload_dialog dcl_id)
- (运行程序);;此处为主要程序运行
- (setvar "osmode" osmode_bak) ;_还原捕捉
- (setvar "cmdecho" 1) ;_打开命令提示
- (princ))
- (defun 读取对话框数据 ()
- (setq t1 (read srsz_bak)))
- (defun 备份数据( / key)(foreach key keys (set (read (strcat key "_bak")) (get_tile key))))
- (defun 运行程序 ()
- (if (= chk 1) ;;此处为自定义条件和执行,可以改成其他的关联方式
- (command "circle" (getpoint) t1)))
- ;;程序结束-----------------------------------
直接复制或者下载,代码一样。
|