958620832 发表于 2013-9-2 21:57:58

自定义面板函数

本帖最后由 958620832 于 2013-9-2 21:59 编辑

dcl文件内容:
xx:dialog {
    label = "自定义面板函数" ;
    :row {
      :boxed_row {
            label = "尺寸" ;
            :column {
                :button {
                  key = "x1" ;
                  label = "标注断开" ;
                }
                :button {
                  key = "x2" ;
                  label = "位置取齐" ;
                }
                :button {
                  key = "x3" ;
                  label = "位置取齐" ;
                }
                :button {
                  key = "x4" ;
                  label = "位置取齐" ;
                }
            }
            :column {
                :button {
                  key = "x5" ;
                  label = "延长线段" ;
                }
                :button {
                  key = "x6" ;
                  label = "延长线段" ;
                }
                :button {}
                :button {}
            }
      }
      :boxed_column {
            label = "文字" ;
            :button {}
            :button {}
            :button {}
            :button {}
      }
    }
    :row {
      :boxed_column {
            label = "修改" ;
            :button {}
            :button {}
            :button {}
            :button {}
      }
      :boxed_row {
            label = "备用" ;
            :column {
                :button {}
                :button {}
                :button {}
                :button {}
            }
            :column {
                :button {}
                :button {}
                :button {}
                :button {}
            }
      }
    }
    cancel_button;
}
lisp文件内容:
(defun c:xx ()
(if (< (setq id (load_dialog "E:\\我的文档\\USB\\自定面板函数2")) 0) (exit))
(if (not (new_dialog "xx" id))(exit))
(setq n 1)
(repeat 4
(action_tile (strcat "x" (rtos n)) "(done_dialog n)")
(setq n (+ n 1)))
(setq sdt (start_dialog))
(setq clist '((c:k1) (c:k2)(c:k3)(c:k4)(c:k5)(c:k6)))
(if (> sdt 0) (eval (nth (- sdt 1) clist)))
(unload_dialog)
(princ))
问题如下:
点击k1,k2,k3,k4按钮,为什么显示的都是(c:k5),而不是k1,k2,k3,k4呢?为什么?难道repeat函数在这里不能用?

nzl1116 发表于 2013-9-2 22:59:06

n 即是变量,在双引号里面肯定是错的,程序有问题。

zlg258369 发表于 2013-9-3 16:21:50

本帖最后由 zlg258369 于 2013-9-3 20:12 编辑

执行(done_dialog n)时已循环完,此时n已经等于5

(action_tile (strcat "x" (rtos n)) "(done_dialog   (atoi (substr $key 2)))")

知行ooo李肖坪 发表于 2016-1-24 07:34:21

同步学习中^^^…………
页: [1]
查看完整版本: 自定义面板函数