明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1791|回复: 10

[已解答] 对话框返回

[复制链接]
发表于 2016-4-1 20:01:27 | 显示全部楼层 |阅读模式
;来自阿甘兄弟的图层控制程序;
;因在线时间少不方便联系作者本人,请路过的朋友出手帮忙
;现在想让 “设当前层” 和 “浏览图层” 2个按钮执行相应CAD命令后,能返回对话框;



;图层控制 命令
;by-阿甘 2014.8.11
;主程序
(vl-load-com)
(defun c:NN (/ fname fn x dclid lin)
       (setq fname (vl-filename-mktemp nil nil ".dcl" ))
       (setq fn (open fname "w" ))
       (foreach x '(
                     "boxedGL:boxed_column{horizontal_margin=none;vertical_margin=none;} //自定义按钮"
                     "buttonGL:button{horizontal_margin=none;vertical_margin=none;} //自定义按钮"
                     "  agtckz : dialog{"
                     "  label=\"阿甘图层控制\";"
                     
                     "     :row{"
                     "     :boxedGL{"
                     "     label=\"图层\";"
                     "     :row{"
                     "      :buttonGL{key=\"1\";label=\"关 闭\";width=10;height=3;}"
                     "      :buttonGL{key=\"2\";label=\"关闭<反>\";width=10;height=3;}"
                     "      :buttonGL{key=\"3\";label=\"全部显示\";width=10;height=3;}"
                     "     }"

                     "     :row{"
                     "      :buttonGL{key=\"4\";label=\"冻 结\";width=10;height=3;}"
                     "      :buttonGL{key=\"5\";label=\"冻结<反>\";width=10;height=3;}"
                     "      :buttonGL{key=\"6\";label=\"全部解冻\";width=10;height=3;}"
                     "     }"
                     
                     "     :row{"
                     "      :buttonGL{key=\"7\";label=\"锁 定\";width=10;height=3;}"
                     "      :buttonGL{key=\"8\";label=\"锁定<反>\";width=10;height=3;}"
                     "      :buttonGL{key=\"9\";label=\"全部解锁\";width=10;height=3;}"
                     "     }"

                     "     :row{"
                     "      :buttonGL{key=\"10\";label=\"全部(显示&解冻&解锁)\";width=10;height=3;}"
                     "     }"  
                     "     }"

                     "     :boxedGL{"
                     "     label=\"状态\";"
                     "      :buttonGL{key=\"11\";label=\"设当前层\";width=10;height=2.35;}";;;;想让此按钮执行CAD命令LAYMCUR后返回对话框
                     "      :buttonGL{key=\"12\";label=\"置换图层\";width=10;height=2.35;}"
                     "      :buttonGL{key=\"13\";label=\"浏览图层\";width=10;height=2.35;}";;;;想让此按钮执行CAD命令laywalk后返回对话框
                     "      :buttonGL{key=\"14\";label=\"状态保存\";width=10;height=2.35;}"
                     "      :buttonGL{key=\"15\";label=\"状态恢复\";width=10;height=2.35;}"
                     "     }"
                     
                     "     :boxedGL{"
                     "     label=\"实体\";"
                     "      :buttonGL{key=\"16\";label=\"默认随层\";width=10;height=2.35;}"
                     "      :buttonGL{key=\"17\";label=\"隐藏图元\";width=10;height=2.35;}"
                     "      :buttonGL{key=\"18\";label=\"隐藏<反>\";width=10;height=2.35;}"
                     "      :buttonGL{key=\"19\";label=\"显示图元\";width=10;height=2.35;}"
                     "      :buttonGL{key=\"cancel\";label=\"退  出\";is_cancel=true;height=2.35;}"
                     "     }"
                     "     }"  
                     "}"
              );end ;endlist
              (princ x fn)
              (write-line "" fn)
       );end foreach
       (close fn)
       (setq fn (open fname "r" ))
       (setq dclid (load_dialog fname))
       (while (or (eq (substr (setq lin (vl-string-right-trim "\" fn)" (vl-string-left-trim "(write-line \"" (read-line fn)))) 1 2) "//" )
              (eq (substr lin 1 (vl-string-search " " lin)) "" )
              (not (eq (substr lin (+ (vl-string-search " " lin) 1) 9) " : dialog" ))))
       (new_dialog (substr lin 1 (vl-string-search " " lin)) dclid)
       (action_tile "1" "(done_dialog 1)" )
       (action_tile "2" "(done_dialog 2)" )
       (action_tile "3" "(done_dialog 3)" )
       (action_tile "4" "(done_dialog 4)" )
       (action_tile "5" "(done_dialog 5)" )
       (action_tile "6" "(done_dialog 6)" )
       (action_tile "7" "(done_dialog 7)" )
       (action_tile "8" "(done_dialog 8)" )
       (action_tile "9" "(done_dialog 9)" )
       (action_tile "10" "(done_dialog 10)" )
       (action_tile "11" "(done_dialog 11)" )
       (action_tile "12" "(done_dialog 12)" )
       (action_tile "13" "(done_dialog 13)" )
       (action_tile "14" "(done_dialog 14)" )
       (action_tile "15" "(done_dialog 15)" )
       (action_tile "16" "(done_dialog 16)" )
       (action_tile "17" "(done_dialog 17)" )
       (action_tile "18" "(done_dialog 18)" )
       (action_tile "19" "(done_dialog 19)" )
       (action_tile "cancel" "(done_dialog 0)" )
      
       (setq re (start_dialog))
       (cond
              ((= re 1) (GL:tcgb))
              ((= re 2) (GL:tcgbf))
              ((= re 3) (GL:tcqbxs))
              ((= re 4) (GL:tcdj))
              ((= re 5) (GL:tcdjf))
              ((= re 6) (GL:tcqbjd))
              ((= re 7) (GL:tcsd))
              ((= re 8) (GL:tcsdf))
              ((= re 9) (GL:tcqbjs))
              ((= re 10) (GL:tcqbxjj))
              ((= re 11) (C:LAYMCUR))
              ((= re 12) (C:BN))
              ((= re 13) (command "laywalk"))
              ((= re 14) (bctczt))
              ((= re 15) (hftczt))
              ((= re 16) (ke:xkyssc))
              ((= re 17) (GL:ycwt))
              ((= re 18) (GL:yfwt))
              ((= re 19) (GL:xswt))
       );end cond
       (unload_dialog dclid)
       (close fn)
       (vl-file-delete fname)
       (princ)
)


该贴已经同步到 冒个烟圈的微博
"觉得好,就打赏"
还没有人打赏,支持一下
 楼主| 发表于 2016-4-2 06:42:11 | 显示全部楼层
请大家指点
发表于 2016-4-2 11:47:43 | 显示全部楼层
给(setq re (start_dialog))前面加个while判断
 楼主| 发表于 2016-4-2 19:21:24 | 显示全部楼层
kozmosovia 发表于 2016-4-2 11:47
给(setq re (start_dialog))前面加个while判断

谢谢指点;
按你说的加while试过了,没成功,还请讲具体点。。
发表于 2016-4-2 21:07:29 | 显示全部楼层
(while (null re)
(setq re (start_dialog))
....
(cond
...
((= re 11) (C:LAYMCUR)(setq re nil))
..
((= re 13) (command "laywalk") (setq re nil))
....
 楼主| 发表于 2016-4-3 08:08:55 来自手机 | 显示全部楼层
kozmosovia 发表于 2016-4-2 21:07
(while (null re)
(setq re (start_dialog))
....

您好!
按以上方式添加后,设当前层这个按钮执行完laymcur命令没有自动返回对话框,再次启动对话框后CAD卡在对话框界面,按任何按键退不出对话框。
请问还有好方法吗?
发表于 2016-4-3 10:21:55 | 显示全部楼层
while位置放错了

  1. (defun c:NN (/ DCLID FN FNAME RE)
  2.   (setq        fname (vl-filename-mktemp nil nil ".dcl")
  3.         fn    (open fname "w")
  4.   )
  5.   (foreach x
  6.            '(
  7.              "boxedGL:boxed_column{horizontal_margin=none;vertical_margin=none;} //自定义按钮"
  8.              "buttonGL:button{horizontal_margin=none;vertical_margin=none;} //自定义按钮"
  9.              "  agtckz : dialog{"
  10.              "  label="阿甘图层控制";"

  11.              "     :row{"
  12.              "     :boxedGL{"
  13.              "     label="图层";"
  14.              "     :row{"
  15.              "      :buttonGL{key="1";label="关 闭";width=10;height=3;}"
  16.              "      :buttonGL{key="2";label="关闭<反>";width=10;height=3;}"
  17.              "      :buttonGL{key="3";label="全部显示";width=10;height=3;}"
  18.              "     }"

  19.              "     :row{"
  20.              "      :buttonGL{key="4";label="冻 结";width=10;height=3;}"
  21.              "      :buttonGL{key="5";label="冻结<反>";width=10;height=3;}"
  22.              "      :buttonGL{key="6";label="全部解冻";width=10;height=3;}"
  23.              "     }"

  24.              "     :row{"
  25.              "      :buttonGL{key="7";label="锁 定";width=10;height=3;}"
  26.              "      :buttonGL{key="8";label="锁定<反>";width=10;height=3;}"
  27.              "      :buttonGL{key="9";label="全部解锁";width=10;height=3;}"
  28.              "     }"

  29.              "     :row{"
  30.              "      :buttonGL{key="10";label="全部(显示&解冻&解锁)";width=10;height=3;}"
  31.              "     }"
  32.              "     }"

  33.              "     :boxedGL{"
  34.              "     label="状态";"
  35.              "      :buttonGL{key="11";label="设当前层";width=10;height=2.35;}"
  36. ;;;;想让此按钮执行CAD命令LAYMCUR后返回对话框
  37.              "      :buttonGL{key="12";label="置换图层";width=10;height=2.35;}"
  38.              "      :buttonGL{key="13";label="浏览图层";width=10;height=2.35;}"
  39. ;;;;想让此按钮执行CAD命令laywalk后返回对话框
  40.              "      :buttonGL{key="14";label="状态保存";width=10;height=2.35;}"
  41.              "      :buttonGL{key="15";label="状态恢复";width=10;height=2.35;}"
  42.              "     }"

  43.              "     :boxedGL{"
  44.              "     label="实体";"
  45.              "      :buttonGL{key="16";label="默认随层";width=10;height=2.35;}"
  46.              "      :buttonGL{key="17";label="隐藏图元";width=10;height=2.35;}"
  47.              "      :buttonGL{key="18";label="隐藏<反>";width=10;height=2.35;}"
  48.              "      :buttonGL{key="19";label="显示图元";width=10;height=2.35;}"
  49.              "      :buttonGL{key="cancel";label="退  出";is_cancel=true;height=2.35;}"
  50.              "     }"
  51.              "     }"
  52.              "}"
  53.             )                                ;end ;endlist
  54.     (princ x fn)
  55.     (write-line "" fn)
  56.   )                                        ;end foreach
  57.   (close fn)
  58.   (setq dclid (load_dialog fname))
  59.   (while (null re)
  60.     (new_dialog "agtckz" dclid)
  61.     (action_tile "1" "(done_dialog 1)")
  62.     (action_tile "2" "(done_dialog 2)")
  63.     (action_tile "3" "(done_dialog 3)")
  64.     (action_tile "4" "(done_dialog 4)")
  65.     (action_tile "5" "(done_dialog 5)")
  66.     (action_tile "6" "(done_dialog 6)")
  67.     (action_tile "7" "(done_dialog 7)")
  68.     (action_tile "8" "(done_dialog 8)")
  69.     (action_tile "9" "(done_dialog 9)")
  70.     (action_tile "10" "(done_dialog 10)")
  71.     (action_tile "11" "(done_dialog 11)")
  72.     (action_tile "12" "(done_dialog 12)")
  73.     (action_tile "13" "(done_dialog 13)")
  74.     (action_tile "14" "(done_dialog 14)")
  75.     (action_tile "15" "(done_dialog 15)")
  76.     (action_tile "16" "(done_dialog 16)")
  77.     (action_tile "17" "(done_dialog 17)")
  78.     (action_tile "18" "(done_dialog 18)")
  79.     (action_tile "19" "(done_dialog 19)")
  80.     (action_tile "cancel" "(done_dialog 0)")
  81.     (setq re (start_dialog))
  82.     (cond
  83.       ((= re 1) (GL:tcgb))
  84.       ((= re 2) (GL:tcgbf))
  85.       ((= re 3) (GL:tcqbxs))
  86.       ((= re 4) (GL:tcdj))
  87.       ((= re 5) (GL:tcdjf))
  88.       ((= re 6) (GL:tcqbjd))
  89.       ((= re 7) (GL:tcsd))
  90.       ((= re 8) (GL:tcsdf))
  91.       ((= re 9) (GL:tcqbjs))
  92.       ((= re 10) (GL:tcqbxjj))
  93.       ((= re 11) (C:LAYMCUR) (setq re nil))
  94.       ((= re 12) (C:BN))
  95.       ((= re 13) (command "laywalk") (setq re nil))
  96.       ((= re 14) (bctczt))
  97.       ((= re 15) (hftczt))
  98.       ((= re 16) (ke:xkyssc))
  99.       ((= re 17) (GL:ycwt))
  100.       ((= re 18) (GL:yfwt))
  101.       ((= re 19) (GL:xswt))
  102.     )
  103.   )                                        ;end cond
  104.   (unload_dialog dclid)
  105.   (vl-file-delete fname)
  106.   (princ)
  107. )
 楼主| 发表于 2016-4-3 11:29:17 来自手机 | 显示全部楼层
现在完全可以了,感谢您的热心解答,又学会了一点。
 楼主| 发表于 2016-4-3 11:31:52 来自手机 | 显示全部楼层
kozmosovia 发表于 2016-4-3 10:21
while位置放错了

现在完全可以了,感谢您的热心解答,又学会了一招。
 楼主| 发表于 2016-4-3 11:36:29 来自手机 | 显示全部楼层
kozmosovia 发表于 2016-4-3 10:21
while位置放错了

再请教一下,您删掉的那几行主要控制哪里或者说是起什么作用的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-20 17:21 , Processed in 0.231861 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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