请教DCL对话框如何记住上次输入的数值?谢谢!
本帖最后由 depgfdepgf 于 2023-1-30 21:36 编辑(setq dcl_file (open (setq tmp-dcl-file-name (vl-filename-mktemp nil nil".DCL")) "w"))
(progn
(foreach x
'(
"dia8b:dialog{"
"label=\"图像按钮辅助【参数设计】范例\";"
":boxed_column{"
"label=\"设计样式\";"
":row{"
":image_button { //图像按钮1"
"key = \"kimage1\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true; "
"}"
":image_button { //图像按钮2"
"key = \"kimage2\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true;"
"}"
"}"
":row{"
":image_button { //图像按钮3"
"key = \"kimage3\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true;"
"}"
":image_button { //图像按钮4"
"key = \"kimage4\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true;"
"}"
"}"
"}"
":row{"
":edit_box{label=\"宽度ww\";key=\"kww\";}"
":edit_box{label=\"高度hh\";key=\"khh\";}"
"}"
"spacer_1;"
"ok_cancel;"
"}"
) (write-line x dcl_file) )
(setq dcl_file (close dcl_file)))
(defun c:TT1 ()
(setvar "cmdecho" 0)
(dcl_dia8b)
(prin1)
)
(defun dcl_dia8b()
(setq dcl_id (load_dialog tmp-dcl-file-name))
(new_dialog "dia8b" dcl_id)
(def_dia8b)
(action_tile "kimage1" "(setq ddtype 1)")
(action_tile "kimage2" "(setq ddtype 2)")
(action_tile "kimage3" "(setq ddtype 3)")
(action_tile "kimage4" "(setq ddtype 4)")
(action_tile "accept" "(ok_dia8b)(done_dialog 1)")
(setq dd(start_dialog))
(if (= dd 1)
(draw_dia8b)
)
)
(defun def_dia8b()
(set_tile "kww" "100")
(set_tile "khh" "100")
(setq sldkey_list '("kimage1" "kimage2" "kimage3" "kimage4"))
(setq sld_list '("dia8a1" "dia8a2" "dia8a3" "dia8a4"));这幻灯片的路径如何设置
(mapcar 'show_sld sldkey_list sld_list)
)
(defun show_sld(key sld)
(setq x (dimx_tile key))
(setq y (dimy_tile key))
(start_image key)
(fill_image 0 0 x y -2)
(slide_image 0 0 x y sld)
(end_image)
)
(defun ok_dia8b()
(setq ww (atof (get_tile "kww")))
(setq hh (atof (get_tile "khh")))
)
(defun draw_dia8b()
(setq pt1 (getpoint "左下角基准点:"))
;以下为三个模块共享的点坐标变量
(setq pt2 (polar pt1 0 ww))
(setq pt3 (polar pt2 (/ pi 2) hh))
(setq pt4 (polar pt3 pi (* ww 0.5)))
(setq pt5 (polar pt4 (* pi 1.5) (* hh 0.5)))
(setq pt6 (polar pt5 pi (* ww 0.5)))
;以下依据不同的类别,调用不同的绘图模式
(cond ((= ddtype 1) (command "pline" pt1 pt2 pt3 pt4 pt5 pt6 "C"))
((= ddtype 2) (command "pline" pt6 pt1 pt2 pt3 pt4 "")
(command "circle" "2p" pt4 pt6))
((= ddtype 3) (command "pline" pt1 pt2 pt3 "")
(command "pline" pt4 pt5 pt6 "")
(command "circle" "2p" pt3 pt4)
(command "circle" "2p" pt6 pt1))
((= ddtype 4) (command "pline" pt1 pt2 pt3 pt4 "a" "a" -180 pt6 "L" "C"))
)
)大佬们这个如何设置幻灯片的路径?
各位大佬,经过修改可以记忆数值了,但成生不了图型 ,不知道哪里出问题的:'(
(defun c:TT4 ()
(setvar "cmdecho" 0)
(dcl_dia8b3)
(prin1)
)
(defun dcl_dia8b3()
(if (= (setq dcl_id (load_dialog (make-dclCS53))) 0)(progn(alert "\n无法显示对话框!")(exit)))
(if(not (new_dialog "dia8b" dcl_id))(progn(alert "\n无法显示对话框!")(exit)))
(if ww (/= 'str (type ww)) (setq ww "300"))
(if hh (/= 'str (type hh)) (setq hh "300"))
(set_tile "kww" ww)
(set_tile "khh" hh)
(def_dia8b3)
(action_tile "popww" "(setq pop 1)(sub_pop3 $value)")
(action_tile "pophh" "(setq pop 2)(sub_pop3 $value)")
(action_tile "kimage1" "(setq ddtype 2)")
(action_tile "kimage2" "(setq ddtype 3)")
(action_tile "kimage3" "(setq ddtype 4)")
(action_tile "kimage4" "(setq ddtype 5)")
(action_tile "accept" "(ok_dia8b3)(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq dd(start_dialog))
(if (= dd 1)
(draw_dia8b3)
))
(defun def_dia8b3 ( / sel)
(setqPATH "D:\\123456\\sld\\") ;;幻灯片的路径设置
(setq sldkey_list '("kimage1" "kimage2" "kimage3" "kimage4"))
(setq sld_list '("dia8a1" "dia8a2" "dia8a3" "dia8a4"))
(foreach x sld_list(setq sel(cons (strcat PATH x) sel))) ;幻灯片与路径接合
(setq sel(reverse sel))
(mapcar 'show_sld3 sldkey_list sel)
(setq ww_list '("50" "60" "70" "80" "90" "100" "120"))
(setq hh_list '("40" "60" "80" "100"))
(show_list3 "popww" ww_list)
(show_list3 "pophh" hh_list)
)
(defun show_sld3 (key sld)
(setq x (dimx_tile key))
(setq y (dimy_tile key))
(start_image key)
(fill_image 0 0 x y -2)
(slide_image 0 0 x y sld)
(end_image)
)
(defun show_list3 (key newlist)
(start_list key)
(mapcar 'add_list newlist)
(end_list)
)
(defun sub_pop3 (vvs)
(if (= pop 1)
(set_tile "kww" (nth (atoi vvs) ww_list))
)
(if (= pop 2)
(set_tile "khh" (nth (atoi vvs) hh_list))
))
(defun ok_dia8b3 ()
(setq ww (get_tile "kww"))
(setq hh (get_tile "khh"))
)
(defun draw_dia8b3 ()
(setq pt1 (getpoint "左下角基准点:"))
;以下为三个模块共享的点坐标变量
(setq pt2 (polar pt1 0 ww))
(setq pt3 (polar pt2 (/ pi 2) hh))
(setq pt4 (polar pt3 pi (* ww 0.5)))
(setq pt5 (polar pt4 (* pi 1.5) (* hh 0.5)))
(setq pt6 (polar pt5 pi (* ww 0.5)))
;以下依据不同的类别,调用不同的绘图模式
(cond
((= ddtype 2)
(command "pline" pt1 pt2 pt3 pt4 pt5 pt6 "C"))
((= ddtype 3)
(command "pline" pt6 pt1 pt2 pt3 pt4 "")
(command "circle" "2p" pt4 pt6))
((= ddtype 3)
(command "pline" pt1 pt2 pt3 "")
(command "pline" pt4 pt5 pt6 "")
(command "circle" "2p" pt3 pt4)
(command "circle" "2p" pt6 pt1))
((= ddtype 4)
(command "pline" pt1 pt2 pt3 pt4 "a" "a" -180 pt6 "L" "C"))
))
(defun make-dclCS53(/ lst_str str file f)
(setq lst_str '(
"dia8b:dialog{"
"label=\"图像按钮辅助【参数设计】范例\";"
":boxed_column{"
"label=\"设计样式\";"
":row{"
":image_button { //图像按钮1"
"key = \"kimage1\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true; "
"}"
":image_button { //图像按钮2"
"key = \"kimage2\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true;"
"}"
"}"
":row{"
":image_button { //图像按钮3"
"key = \"kimage3\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true;"
"}"
":image_button { //图像按钮4"
"key = \"kimage4\";"
"color = -2;"
"width = 30;"
"aspect_ratio = 0.66;"
"allow_accept = true;"
"}"
"}"
"}"
":row{"
":edit_box{label=\"宽度ww\";key=\"kww\";}"
" :popup_list{key=\"popww\";edit_width=8;}"
":edit_box{label=\"高度hh\";key=\"khh\";}"
" :popup_list{key=\"pophh\";edit_width=8;}"
"}"
":row{"
":button{label=\"确定(&Q)\";key=\"accept\";is_default=true;height=2;}"
":button{label=\"取消(&C)\";key=\"cancel\";is_cancel=true;height=2;}""}"
" fixed_width=true;"
" alignment=left;"
" } // end dll" ;结尾
))
(setq file (vl-filename-mktemp "DclTemp.dcl"))
(setq f (open file "w"))
(foreach str lst_str
(princ "\n" f)
(princ str f)
)
(close f)
;;返回
file
)
;;--------------------------------------------------------------------------------
本帖最后由 自贡黄明儒 于 2023-1-31 07:19 编辑
depgfdepgf 发表于 2023-1-15 22:46
@lee50310大佬,请问记住上次输入的数值应该如何修改?
在对话框消失前,用get_tile获取key的值,然后保存在注册表或者.txt文件中。
击ok时执行(ok_dia8b),取得ww,可将ww保存下来,以便下次(def_dia8b)时使用 幻燈片放至 d槽tmp 的 sld 資料夾內
若位置有異動 需修改程式 此行 (setq PATH "D:\\tmp\\sld\\")
執行指令:tt2
谢谢大佬的帮助!感谢!!!{:1_1:} chenbh2
是否通信线路用?
长途杆路生成插件
http://bbs.mjtd.com/thread-184335-1-1.html 好东西,支持一下 @lee50310大佬{:1_1:},请问记住上次输入的数值应该如何修改? 多段线上的文字方向如何改变呢,请问调整那个位置的参数呢 幻灯片面板示意,无实际功能,看书练习学习一下,太难了 也可以定义一个临时变量来存储这个值,注意首次运行时设定值。
页:
[1]
2