(defun c:tt () ; 此部分是测试代码用
(main_load)
(print bl)
(print zg)
(print bh)
)
//-------------------------------------
(defun main_load (/ *error* dcl_file dcl_id dialog_return e_h e_v key keys)
(vl-load-com)
(setq dcl_id (load_dialog (setq Dcl_File (dclfile_load)))) ; 对话框加载
(vl-file-delete Dcl_File) ; 加载后删除DCL文件
(setq Dialog_Return 10)
(while (> Dialog_Return 1) ; 循环控制对话框是否结束
(new_dialog "dcl_bg" dcl_id) ; 建立窗体
; --->--->---对话框初始化--->--->---
(setq keys '("e_bl" "e_zg" "e_h" "e_v" "e_bh"
"e_x1" "e_y1"
"e_x2" "e_y2"
"but_s1" "but_s2"
"accept" "cancel"
)
) ; 列表全部控件名称
(foreach key keys ; 全部控件的初始化
(cond
((= key "e_bl") ; {"图纸比例"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "20.0")
) ; 控件内容
()
)
((= key "e_zg") ; {"字体高度"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "2.50")
) ; 控件内容
()
)
((= key "e_h") ; {"横向"} (单选按钮)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "1")
) ; 控件内容
(setq e_h (atoi (get_tile "e_h")))
(setq e_v (atoi (get_tile "e_v")))
)
((= key "e_v") ; {"纵向"} (单选按钮)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
) ; 控件内容
(setq e_h (atoi (get_tile "e_h")))
(setq e_v (atoi (get_tile "e_v")))
)
((= key "e_bh") ; {"起始坐标编号"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "0")
) ; 控件内容
()
)
((= key "e_x1") ; {"X(mm)"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "0.00")
) ; 控件内容
()
)
((= key "e_y1") ; {"Y(mm)"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "0.00")
) ; 控件内容
()
)
((= key "e_x2") ; {"X(mm)"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "0.00")
) ; 控件内容
()
)
((= key "e_y2") ; {"Y(mm)"} (输入框)
(if (eval (read (strcat key "_bak")))
(set_tile key (eval (read (strcat key "_bak"))))
(set_tile key "0.00")
) ; 控件内容
()
)
)
)
(foreach key keys ; 全部控件的点击动作触发
(action_tile key "(Action_Keys $key $value)") ; 点击动作 $reason
)
; ---<---<---对话框初始化完成---<---<---
;====================================
(if but_s1
(progn
(set_tile "e_x1" (rtos (car but_s1)))
(set_tile "e_y1" (rtos (cadr but_s1))
)
)
)
(if but_s2
(progn
(set_tile "e_x2" (rtos (car but_s2)))
(set_tile "e_y2" (rtos (cadr but_s2))
)
)
)
;====================================
(setq Dialog_Return (start_dialog));开启对话框(用户可见)
;====================================
(cond
((= Dialog_Return 2)(setq but_s1 (getpoint)))
((= Dialog_Return 3)(setq but_s2 (getpoint)))
)
;====================================
)
(unload_dialog dcl_id) ; 退出时卸载对话框
(cond
((= Dialog_Return 1)
(cond
((= e_h 1)
(start "横向")
)
((= e_v 1)
(start "纵向")
)
);end cond
);1
((= Dialog_Return 0)
(princ "\n*取消*")
);0
);end cond
(prin1) ; 防止函数回显
)
//-------------------------------------
(defun Action_Keys (key value) ; 全部控件的点击动作触发
(cond
((= key "accept") ; {"确认按钮"}
(get_data)
(setq bl (atoi (get_tile "e_bl")))
(setq zg (atoi (get_tile "e_zg")))
(setq bh (atoi (get_tile "e_bh")))
(done_dialog 1) ; 对话框退出返回主函数 传递给Dialog_Return值为1
)
((= key "cancel") ; {"取消按钮"}
(done_dialog 0) ; 对话框退出返回主函数 传递给Dialog_Return值为0
)
((= key "help") ; {"帮助按钮"}
() ;
)
((= key "info") ; {"信息按钮"}
() ;
)
((= key "e_bl") ; {"图纸比例"} (输入框)
()
)
((= key "e_zg") ; {"字体高度"} (输入框)
()
)
((= key "e_h") ; {"横向"} (单选按钮)
(setq e_h (atoi (get_tile "e_h")))
(setq e_v (atoi (get_tile "e_v")))
)
((= key "e_v") ; {"纵向"} (单选按钮)
(setq e_h (atoi (get_tile "e_h")))
(setq e_v (atoi (get_tile "e_v")))
)
((= key "e_bh") ; {"起始坐标编号"} (输入框)
()
)
((= key "but_s1") ; {"基点坐标<"} (按钮)
(done_dialog 2)
)
((= key "e_x1") ; {"X(mm)"} (输入框)
()
)
((= key "e_y1") ; {"Y(mm)"} (输入框)
()
)
((= key "but_s2") ; {"表格左上角<"} (按钮)
(done_dialog 3)
)
((= key "e_x2") ; {"X(mm)"} (输入框)
()
)
((= key "e_y2") ; {"Y(mm)"} (输入框)
()
)
)
)
;;; -------------------------------------
(defun get_data (/ key) ; 临时生成Dcl文件 返回文件名
(foreach key keys
(set (read (strcat key "_bak")) (get_tile key)) ; 每个控件都赋给一个变量 用于下次开启初始化
)
)
;;; -------------------------------------
(defun start (num)
(alert (strcat "你选择的是" num))
)
;;; -------------------------------------
;;; ==================DCL文件===================
(defun dclfile_load (/ Dcl_File file )
(setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
(setq file (open Dcl_File "w"))
(write-line "
dcl_bg:dialog {
label = \"【坐标表格】(QQ:)\" ;
:column {
width = 15 ;
:boxed_row {
label = \"比例和字体\" ;
:edit_box {
key = \"e_bl\" ;
label = \"比例\" ;
}
:edit_box {
key = \"e_zg\" ;
label = \"字高\" ;
}
}
:boxed_radio_row {
label = \"板式\" ;
:radio_button {
key = \"e_h\" ;
label = \"横向\" ;
}
:radio_button {
key = \"e_v\" ;
label = \"纵向\" ;
}
}
:boxed_column {
label = \"定位点\" ;
:row {
:boxed_column {
label = \"图形\" ;
:button {
key = \"but_s1\" ;
label = \"基 点>\" ;
}
:edit_box {
key = \"e_x1\" ;
label = \"X\" ;
}
:edit_box {
key = \"e_y1\" ;
label = \"Y\" ;
}
}
:boxed_column {
label = \"表格\" ;
:button {
key = \"but_s2\" ;
label = \"左上角 >\" ;
}
:edit_box {
key = \"e_x2\" ;
label = \"X\" ;
}
:edit_box {
key = \"e_y2\" ;
label = \"Y\" ;
}
}
}
:boxed_row {
label = \"编号\" ;
:edit_box {
key = \"e_qz\" ;
label = \"前缀\" ;
}
:edit_box {
key = \"e_bh\" ;
label = \"编号\" ;
}
}
}
}
ok_cancel;
}
" file)
(close file)
Dcl_File
)