wzg356 发表于 2023-1-31 21:23:57

以参数形式进入对话框,对话框输出参数,参数设为全局变量即可

方法之一 这种形式http://bbs.mjtd.com/thread-187061-1-1.html


depgfdepgf 发表于 2023-2-1 20:57:47

各位大佬,经过修改可以记忆数值了,但成生不了图型 ,不知道哪里出问题的:'(

(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
)
;;--------------------------------------------------------------------------------


页: 1 [2]
查看完整版本: 请教DCL对话框如何记住上次输入的数值?谢谢!