马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 Free-Lancer 于 2014-10-10 17:32 编辑
- (defun c:tt (/ strl fn id what_next
- _Fromdrawing k1 k2 fill lst1
- lst2 result
- )
- ;;通过选择获取 list 填充用的表
- (defun _Fromdrawing (mod / ss e el)
- (cond
- ((= mod 2)
- (if (setq ss (ssget '((0 . "*line,arc,circle,ellipse"))))
- (progn
- (setq lst1
- (mapcar '(lambda (x)
- (vl-princ-to-string (cadr (xdrx_getarea x)))
- )
- (xdrx_pickset->ents ss)
- )
- ) ;_构造表一用的填充表
- )
- )
- )
- ((= mod 3)
- (while (and (setq e (car (entsel "\nPick text: ")))
- (setq el (entget e))
- (= (cdr (assoc 0 el)) "TEXT")
- )
- (setq lst2 (cons (cdr (assoc 1 el)) lst2))
- ) ;_构造表二用的填充表
- )
- (t)
- )
- )
- (defun _calc ()
- (set_tile
- "k7"
- (vl-princ-to-string
- (apply '+ (mapcar 'distof (xd::dcl:gettile '("k3" "k5"))))
- )
- )
- )
- (defun fill (mod /)
- (if (= mod 1)
- (set_tile "k3" k1) ;_ list 1 的值
- (set_tile "k5" k2) ;_ list 2 的值
- )
- ) ;_将 List 选择填入 edit_box
- (setq strl '("temp:dialog{"
- "label = \"button test\";"
- " :row{"
- " :list_box {label = \"num\"; width = 8; height = 12; key = \"k1\";}"
- " :list_box {label = \"dist\"; width = 8; height = 12; key = \"k2\";}"
- " }"
- " :row{"
- " :edit_box {width = 6;key = \"k3\";}"
- " :text {width = 4;key=\"k4\";value = \"+\";}"
- " :edit_box {width = 6; key = \"k5\";}"
- " :text {width = 4; key = \"k6\"; value = \"=\";}"
- " :edit_box { width = 6; key = \"k7\";}"
- " }"
- " :row {"
- " :button {label = \"Select\"; width = 6; key = \"k8\";}"
- " :button {label = \"Pick\"; width = 6; key = \"k9\";}"
- " :button {label = \"Calc\"; width = 6; key = \"k10\";}"
- " }"
- " ok_cancel;"
- " errtile;"
- "}"
- )
- fn (xd::dcl:make strl)
- what_next 2
- result '("k7") ;_点击ok 时获取的 key $value列表
- )
- (while (>= what_next 2)
- (setq id (xd::dcl:load fn "temp")) ;_有回调函数时需要将 load 放到循环体内
- (xd::dcl:buttonaction
- '("k8" "k9" "k10")
- '(2 3 "_calc") ;_按钮的回调函数
- ) ;_定义按钮动作
- (xd::dcl:listaction
- '("k1" "k2")
- '(lst1 lst2) ;_在 按钮动作时 获取列表
- nil;_不确定索引
- '("fill 1" "fill 2");_回调函数,可以带参数
- ) ;_定义 list 的关联动作
- (xd::dcl:accept 'result) ;_定义 ok cancel , 获取 ok 后需要的控件值
- (setq what_next (xd::dcl:show)) ;_控制权交给 DCL
- (_Fromdrawing what_next);_图形交互时执行的函数
- )
- (if (= what_next 1)
- (progn
- (princ (car result))
- )
- )
- (xd::dcl:unload id fn)
- (princ)
- )
|