明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 996|回复: 12

[讨论] 请教DCL对话框如何记住上次输入的数值?谢谢!

[复制链接]
发表于 2022-8-13 21:37 | 显示全部楼层 |阅读模式
本帖最后由 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"))
)
)大佬们这个如何设置幻灯片的路径?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2023-2-1 20:57 | 显示全部楼层
各位大佬,经过修改可以记忆数值了,但成生不了图型 ,不知道哪里出问题的

(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)
   (setq  PATH "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
  )
;;--------------------------------------------------------------------------------


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2023-1-31 07:13 | 显示全部楼层
本帖最后由 自贡黄明儒 于 2023-1-31 07:19 编辑
depgfdepgf 发表于 2023-1-15 22:46
@lee50310大佬,请问记住上次输入的数值应该如何修改?

在对话框消失前,用get_tile获取key的值,然后保存在注册表或者.txt文件中。
击ok时执行(ok_dia8b),取得ww,可将ww保存下来,以便下次(def_dia8b)时使用
发表于 2022-8-14 12:26 | 显示全部楼层
幻燈片放至 d槽  tmp 的 sld 資料夾內

若位置有異動 需修改程式 此行 (setq PATH "D:\\tmp\\sld\\")

執行指令:tt2




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

点评

是否通信线路用?  发表于 2022-8-14 15:02

评分

参与人数 1明经币 +1 收起 理由
depgfdepgf + 1 很给力!

查看全部评分

 楼主| 发表于 2022-8-14 12:41 | 显示全部楼层
谢谢大佬的帮助!感谢!!!
发表于 2022-8-15 12:06 | 显示全部楼层
chenbh2
是否通信线路用?


长途杆路生成插件
http://bbs.mjtd.com/thread-184335-1-1.html
发表于 2022-9-30 16:07 | 显示全部楼层
好东西,支持一下
 楼主| 发表于 2023-1-15 22:46 | 显示全部楼层
@lee50310大佬,请问记住上次输入的数值应该如何修改?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2023-1-16 08:35 | 显示全部楼层
多段线上的文字方向如何改变呢,请问调整那个位置的参数呢
 楼主| 发表于 2023-1-30 21:39 | 显示全部楼层
幻灯片面板示意,无实际功能,看书练习学习一下,太难了
发表于 2023-1-31 21:17 来自手机 | 显示全部楼层
也可以定义一个临时变量来存储这个值,注意首次运行时设定值。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-21 11:55 , Processed in 0.175619 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表