本帖最后由 hhh454 于 2023-12-31 20:53 编辑
输入数据多,用dcl好一点,程序输入数据一次后,关闭文件前都会记忆数据,关闭文件后,数据清空,需要重新输入。
对话框没有给定输入框的宽度参数,所以长短不一,不太美观,不影响使用。
- ;对话框程序开始:
- (defun ngc-dcl()
- (setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
- (setq f_dcl (open Dcl_File "w"))
- ;;下面的对话框名称,和下面的对应,可以改成自己的名称,要上下对应:
- (write-line "sjct33:dialog{label=\"可视化DCL\";:row{:boxed_column{ label = \"春婵工具\";:row{:column{:row{:edit_box{key = \"edit3\"; label = \"输入离结构基准面高度\" ;}}:row{:edit_box{key = \"edit4\"; label = \"输入距边距离左侧负数右侧正数\" ;}}:row{:edit_box{key = \"edit5\"; label = \"输入pa距离\" ;}}:row{:edit_box{key = \"edit6\"; label = \"输入pb距离\" ;}}:row{:edit_box{key = \"edit7\"; label = \"输入pc距离\" ;}}:row{:edit_box{key = \"edit8\"; label = \"输入pd距离\" ;}}:row{:edit_box{key = \"edit9\"; label = \"输入pe距离\" ;}}:row{:edit_box{key = \"edit10\"; label = \"输入圆直径\" ;}}:row{:text{key = \"txt11\"; label = \"春婵绘图工具\" ;}}}}}}ok_cancel;}" 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 "sjct33" DCL_ID);;此处为对话框名称,和上面对应,要上下对应
- (setq keys '("edit3" "edit4" "edit5" "edit6" "edit7" "edit8" "edit9" "edit10" "txt11" "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 edit3_bak))
- (SETQ T2 (read edit4_bak))
- (SETQ T3 (read edit5_bak))
- (SETQ T4 (read edit6_bak))
- (SETQ T5 (read edit7_bak))
- (SETQ T6 (read edit8_bak))
- (SETQ T7 (read edit9_bak))
- (SETQ T8 (read edit10_bak))
- )
- (defun 备份数据( / key)(foreach key keys (set (read (strcat key "_bak")) (get_tile key))))
- (DEFUN 运行程序 ()
- (IF (= CHK 1) ;;此处为自定义条件和执行,可以改成其他的关联方式
- (progn
- (setq p1(getpoint"请指定第一点"))
- (setq x (car p1)
- y (cadr p1))
- (setq pa(list (+ x T2) (+ y (- T3 T1)))
- pb(list (+ x T2) (+ y (- T4 T1)))
- pc(list (+ x T2) (+ y (- T5 T1)))
- pd(list (+ x T2) (+ y (- T6 T1)))
- pe(list (+ x T2) (+ y (- T7 T1))))
- (command "circle" pa "d" t8)
- (command "circle" pb "d" t8)
- (command "circle" pc "d" t8)
- (command "circle" pd "d" t8)
- (command "circle" pe "d" t8)
- );;end progn
- );;end if
- )
- ;;程序结束-----------------------------------
|