明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1282|回复: 7

[源码] 为什么get_tile获取不到值,大神帮帮忙

[复制链接]
发表于 2018-10-8 17:08:17 | 显示全部楼层 |阅读模式
本帖最后由 lifuq1979 于 2018-10-8 17:14 编辑

(defun c:TT ()
  (setvar "cmdecho" 0)                       
  (command ".UNDO" "BE")
  (setq pt(getpoint "文字注记位置:"))
        (insdcl2)
        (entmake (list '(0 . "TEXT")(cons 1 txt)(cons 8 "ZJ")(cons 10 pt)(cons 40 3)(cons 41 0.8 )(cons 62 7)))
        (setvar "cmdecho" 1)                       
  (command ".UNDO" "E")
        (PRINC)
)
(defun insdcl2 (/ dclname dlg f x)
    (defun show_list (key newlist)
      (start_list key)(mapcar 'add_list newlist ) (end_list))
    (defun insdcl03 (i)
      (if (/= i bz001) (setq bz002 "0"))
      (setq lst2 (cdr (nth (atoi i) lst)) str0 (nth (atoi bz002) lst2) bz001 i)
      (show_list "e03" lst2)
      (set_tile "e01"  str0) (set_tile "e03" bz002)
                )
    (defun insdcl04 (j)
      (setq str0 (nth (atoi j) lst2) bz002 j )
      (set_tile "e01" str0 ))
    (setq lst '()
          lst (cons (list "居民地" "砼" "混" "砖" "建" "简" "土" "破") lst)
          lst (cons (list "植被" "苗" "松" "杉" "杂" "桔" "柚" "李" ) lst )
          lst (cons (list "路面性质" "水泥" "碎石" "土" ) lst )
          lst (cons (list "其它注记" "空坪" "施工地") lst)
          lst (reverse lst)
    )
    (setq lst1 (mapcar 'car lst ) lst2 (cdr (car lst)) dclname (vl-filename-mktemp "re-dcl-tmp.dcl") f (open dclname "w"))
    (foreach x (list "RENAME:dialog {" "    label = \"文字注记\" ;"
                                                                     "        :edit_box  {  key = \"e01\" ;  }" "   :row {"
                     "        :list_box { key = \"e02\" ;  width = 15 ; height = 10 ;}"
                     "        :list_box { key = \"e03\" ;  width = 15 ; height = 10 ;allow_accept=true;}}" "    :row {"
                     "        :button {is_default = true ; key = \"e04\" ; label = \"确认\" ; }"
                     "        :button { is_cancel = true ; key = \"e05\" ; label = \"取消\" ; }" "         }}" )
      (write-line x f))
    (close f)
    (setq dcl_re (load_dialog dclname))
    (new_dialog "RENAME" dcl_re)
    (show_list "e02" lst1)
    (if (null bz001) (setq bz001 "0"))
    (if (null bz002) (setq bz002 "0"))
    (set_tile "e02" bz001)
    (insdcl03 bz001)
    (action_tile "e02" "(insdcl03  $value  )  ")
    (action_tile "e03" "(insdcl04  $value  )  ")
    (action_tile "accept" "(setq txt (get_tile \"e01\"))(done_dialog 1)")
    (action_tile "cancel" "(done_dialog 0)")
    (setq bb (start_dialog))
    (unload_dialog dcl_re)
    (vl-file-delete dclname)
    (if (= bb 0)(exit))
  )

大神帮看看问题出在哪,我调试(setq txt (get_tile \"e01\"))返回nil,什么原因?
程序对话框参照郎大师帖子http://bbs.mjtd.com/forum.php?mo ... 5%C8%EB%B7%FB%BA%C5
发表于 2018-10-8 22:57:16 | 显示全部楼层
其实你完全没必要读取那个值,直接把TXT设为STR0不就可以了么。如果硬要的话,试试把get_tile写在前面。。
  1.     (defun insdcl03 (i)
  2.       (if (/= i bz001) (setq bz002 "0"))
  3.       (setq lst2 (cdr (nth (atoi i) lst)) str0 (nth (atoi bz002) lst2) bz001 i)
  4.       (show_list "e03" lst2)
  5.       (set_tile "e01"  str0) (set_tile "e03" bz002)
  6.       (setq txt (get_tile "e01"))
  7.                 )
  8.     (defun insdcl04 (j)
  9.       (setq str0 (nth (atoi j) lst2) bz002 j )
  10.       (set_tile "e01" str0 )
  11.       (setq txt (get_tile "e01"))
  12.     )

 楼主| 发表于 2018-10-9 18:18:29 | 显示全部楼层
本帖最后由 lifuq1979 于 2018-10-9 18:27 编辑
evayleung 发表于 2018-10-8 22:57
其实你完全没必要读取那个值,直接把TXT设为STR0不就可以了么。如果硬要的话,试试把get_tile写在前面。。
...

我之前就是直接用str0的,但我想要有即可选择,又可输入的效果,就如下图在选择松再在后面输入9要有松9的结果,按你那样点确定后还是松而不是松9,大师帮出个招啊!


本帖子中包含更多资源

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

x
发表于 2018-10-9 22:31:05 | 显示全部楼层
  1. (defun c:TTt ()
  2.   (setvar "cmdecho" 0)                       
  3.   (command ".UNDO" "BE")
  4.   (setq pt(getpoint "文字注记位置:"))
  5.         (insdcl2)
  6.         (entmake (list '(0 . "TEXT")(cons 1 txt)(cons 10 pt)(cons 40 3)(cons 41 0.8 )(cons 62 7)))
  7.         ;(entmake (list '(0 . "TEXT") (cons 1 txt) (cons 10 pt) (cons 40 5)))
  8.         (setvar "cmdecho" 1)                       
  9.   (command ".UNDO" "E")
  10.         (PRINC)
  11. )
  12. (defun insdcl2 (/ dclname dlg f x)
  13.     (defun show_list (key newlist)
  14.       (start_list key)(mapcar 'add_list newlist ) (end_list))
  15.     (defun insdcl03 (i)
  16.       (if (/= i bz001) (setq bz002 "0"))
  17.       (setq lst2 (cdr (nth (atoi i) lst)) str0 (nth (atoi bz002) lst2) bz001 i)
  18.       (show_list "e03" lst2)
  19.       (set_tile "e01"  str0) (set_tile "e03" bz002)
  20.       
  21.                 )
  22.     (defun insdcl04 (j)
  23.       (setq str0 (nth (atoi j) lst2) bz002 j )
  24.       (set_tile "e01" str0 )
  25.       
  26.     )
  27.     (setq lst '()
  28.           lst (cons (list "居民地" "砼" "混" "砖" "建" "简" "土" "破") lst)
  29.           lst (cons (list "植被" "苗" "松" "杉" "杂" "桔" "柚" "李" ) lst )
  30.           lst (cons (list "路面性质" "水泥" "碎石" "土" ) lst )
  31.           lst (cons (list "其它注记" "空坪" "施工地") lst)
  32.           lst (reverse lst)
  33.     )
  34.     (setq lst1 (mapcar 'car lst ) lst2 (cdr (car lst)) dclname (vl-filename-mktemp "re-dcl-tmp.dcl") f (open dclname "w"))
  35.     (foreach x (list "RENAME:dialog {" "    label = \"文字注记\" ;"
  36.                      "   :edit_box  {  key = \"e01\" ;  }"
  37.                      "   :row {"
  38.                      "        :list_box { key = \"e02\" ;  width = 15 ; height = 10 ;}"
  39.                      "        :list_box { key = \"e03\" ;  width = 15 ; height = 10 ;}}"
  40.                      "    :row {"
  41.                      "        :button {is_default = true ; key = \"e04\" ; label = \"确认\" ; }"
  42.                      "        :button { is_cancel = true ; key = \"e05\" ; label = \"取消\" ; }"
  43.                      "         }}"
  44.                )
  45.       (write-line x f))
  46.     (close f)
  47.     (setq dcl_re (load_dialog dclname))
  48.     (new_dialog "RENAME" dcl_re)
  49.     (show_list "e02" lst1)
  50.     (if (null bz001) (setq bz001 "0"))
  51.     (if (null bz002) (setq bz002 "0"))
  52.     (set_tile "e02" bz001)
  53.     (insdcl03 bz001)
  54.     (action_tile "e02" "(insdcl03  $value  )  ")
  55.     (action_tile "e03" "(insdcl04  $value  )  ")
  56.     (action_tile "e01" "(Setq txt $Value)")
  57.     (action_tile "accept" "(done_dialog 1)")
  58.     (action_tile "cancel" "(done_dialog 0)")
  59.     (setq bb (start_dialog))
  60.     (unload_dialog dcl_re)
  61.     (vl-file-delete dclname)
  62.     (if (= bb 0)(exit))
  63.   )

这样子呢?
发表于 2018-10-9 22:34:04 | 显示全部楼层
加多一行这个
  1. (action_tile "e01" "(Setq txt $Value)")

前面的那个ENTMAKE我改了下,因为我没那些图层。就改简单些,你用回原来的就行。
  1. (foreach x (list "RENAME:dialog {" "    label = \"文字注记\" ;"
  2.                      "   :edit_box  {  key = \"e01\" ;  }"
  3.                      "   :row {"
  4.                      "        :list_box { key = \"e02\" ;  width = 15 ; height = 10 ;}"
  5.                      "        :list_box { key = \"e03\" ;  width = 15 ; height = 10 ;}}"
  6.                      "    :row {"
  7.                      "        :button {is_default = true ; key = \"e04\" ; label = \"确认\" ; }"
  8.                      "        :button { is_cancel = true ; key = \"e05\" ; label = \"取消\" ; }"
  9.                      "         }}"
  10.                )
  11.       (write-line x f))

这个也改了一下。
 楼主| 发表于 2018-10-10 17:42:48 | 显示全部楼层
evayleung 发表于 2018-10-9 22:34
加多一行这个

前面的那个ENTMAKE我改了下,因为我没那些图层。就改简单些,你用回原来的就行。

谢谢evayleung的回复,按照以上修改,输入是有效了,可是直接选取不点“e01”输入框又出错了,最后按你修改的再将txt改成str0问题解决,谢谢evayleung,谢谢所有为他人解惑的老师们
发表于 2018-10-10 20:49:10 | 显示全部楼层
本帖最后由 evayleung 于 2018-10-10 20:50 编辑
lifuq1979 发表于 2018-10-10 17:42
谢谢evayleung的回复,按照以上修改,输入是有效了,可是直接选取不点“e01”输入框又出错了,最后按你修 ...

我也没注意这个问题,毕竟不是自己的LSP。:D
发表于 2018-10-11 00:41:35 | 显示全部楼层
lifuq1979 发表于 2018-10-10 17:42
谢谢evayleung的回复,按照以上修改,输入是有效了,可是直接选取不点“e01”输入框又出错了,最后按你修 ...

  1. (defun c:TTt ()
  2.   (setvar "cmdecho" 0)                       
  3.   (command ".UNDO" "BE")
  4.   (setq pt(getpoint "文字注记位置:"))
  5.         (insdcl2)
  6.         (entmake (list '(0 . "TEXT")(cons 1 txt)(cons 8 "ZJ")(cons 10 pt)(cons 40 3)(cons 41 0.8 )(cons 62 7)))
  7.         (setvar "cmdecho" 1)                       
  8.   (command ".UNDO" "E")
  9.         (PRINC)
  10. )
  11. (defun insdcl2 (/ dclname dlg f x)
  12.     (defun show_list (key newlist)
  13.       (start_list key)(mapcar 'add_list newlist ) (end_list))
  14.     (defun insdcl03 (i)
  15.       (if (/= i bz001) (setq bz002 "0"))
  16.       (setq lst2 (cdr (nth (atoi i) lst)) str0 (nth (atoi bz002) lst2) bz001 i)
  17.       (show_list "e03" lst2)
  18.       (set_tile "e01"  str0) (set_tile "e03" bz002)
  19.       
  20.                 )
  21.     (defun insdcl04 (j)
  22.       (setq str0 (nth (atoi j) lst2) bz002 j )
  23.       (set_tile "e01" str0 )
  24.       
  25.     )
  26.     (setq lst '()
  27.           lst (cons (list "居民地" "砼" "混" "砖" "建" "简" "土" "破") lst)
  28.           lst (cons (list "植被" "苗" "松" "杉" "杂" "桔" "柚" "李" ) lst )
  29.           lst (cons (list "路面性质" "水泥" "碎石" "土" ) lst )
  30.           lst (cons (list "其它注记" "空坪" "施工地") lst)
  31.           lst (reverse lst)
  32.     )
  33.     (setq lst1 (mapcar 'car lst ) lst2 (cdr (car lst)) dclname (vl-filename-mktemp "re-dcl-tmp.dcl") f (open dclname "w"))
  34.     (foreach x (list "RENAME:dialog {" "    label = \"文字注记\" ;"
  35.                      "   :edit_box  {  key = \"e01\" ;  }"
  36.                      "   :row {"
  37.                      "        :list_box { key = \"e02\" ;  width = 15 ; height = 10 ;}"
  38.                      "        :list_box { key = \"e03\" ;  width = 15 ; height = 10 ;}}"
  39.                      "    :row {"
  40.                      "        :button {is_default = true ; key = \"e04\" ; label = \"确认\" ; }"
  41.                      "        :button { is_cancel = true ; key = \"e05\" ; label = \"取消\" ; }"
  42.                      "         }}"
  43.                )
  44.       (write-line x f))
  45.     (close f)
  46.     (setq dcl_re (load_dialog dclname))
  47.     (new_dialog "RENAME" dcl_re)
  48.     (show_list "e02" lst1)
  49.     (if (null bz001) (setq bz001 "0"))
  50.     (if (null bz002) (setq bz002 "0"))
  51.     (set_tile "e02" bz001)
  52.     (insdcl03 bz001)
  53.     (action_tile "e02" "(insdcl03  $value  )(Setq txt (get_tile \"e01\"))  ")
  54.     (action_tile "e03" "(insdcl04  $value  )(Setq txt (get_tile \"e01\"))  ")
  55.     (action_tile "e01" "(Setq txt $Value)")
  56.     (action_tile "accept" "(done_dialog 1)")
  57.     (action_tile "cancel" "(done_dialog 0)")
  58.     (setq bb (start_dialog))
  59.     (unload_dialog dcl_re)
  60.     (vl-file-delete dclname)
  61.     (if (= bb 0)(exit))
  62.   )

这次好像可以了。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-19 07:14 , Processed in 0.191582 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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