aws 发表于 2024-7-27 12:59:24

关于dcl控件动作触发问题

本帖最后由 aws 于 2024-7-27 13:00 编辑

(defun c:tt()
(setq lst
    '(
       "diy:dialog{"
       "label = \"dcl名称\";"
       ":popup_list{"
       "label = \"选择材料:\";"
       "key = \"k-a\";"
       "width = 40;"
       "fixed_width = true;"
       "list = \"钢铁\\n玻璃\\n木头\";"
       "}"
       ":edit_box{"
       "key = \"k-b\";"
       "label = \"属性\";"
       "value = 1;"
       "}"
       ":button{"
       "key = \"k-c\";"
       "label = \"拾取曲线\";"
       "}"
       ":edit_box{"
       "key = \"k-d\";"
       "label = \"图元名\";"
      
       "}"
       "ok_cancel;"
       "}"
   )
)
(setq dcl_file(vl-filename-mktemp nil nil ".dcl"))
(setq file(open dcl_file "w"))
(foreach str lst(write-line str file))
(close file)
(setq dcl_id(load_dialog dcl_file))
(vl-file-delete dcl_file)
(new_dialog "diy" dcl_id)

(action_tile "ok" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(action_tile "k-a" "(popup(setq v $value))")
(action_tile "k-c" "(button)")

(setq idd(start_dialog))
(unload_dialog dcl_id)
(princ)
)
;---下拉菜单触发
(defun popup(v /)
(cond
    ((= v 0)(set_tile "k-b" 1))
    ((= v 1)(set_tile "k-b" 2))
    ((= v 2)(set_tile "k-b" 3))
)
)
;---按钮菜单触发
(defun button(v /)
    (set_tile "k-d"(car(entsel "选取一根曲线:")))
)
请教大家,这是一个错误的程序,我想要实现这样的功能,请问怎么修改呢?

xyp1964 发表于 2024-7-27 21:39:40

(defun c:tt ()
(setq lst '("diy:dialog{label=\"dcl名称\";"
               ":popup_list{label=\"选择材料:\";key=\"k-a\";width=40;fixed_width=true;list=\"钢铁\\n玻璃\\n木头\";}"
               ":edit_box{key=\"k-b\";label=\"属性\";value=1;}"
               ":button{key=\"k-c\";label=\"拾取曲线\";}"
               ":edit_box{key=\"k-d\";label=\"图元名\";}"
               "ok_cancel;}"
               )
      dcl_file (vl-filename-mktemp nil nil ".dcl")
      file (open dcl_file "w")
)
(foreach str lst (write-line str file))
(close file)
(setq dcl_id (load_dialog dcl_file))
(vl-file-delete dcl_file)
(new_dialog "diy" dcl_id)
(action_tile "ok" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(action_tile "k-a" "(popup(setq v $value))")
(action_tile "k-c" "(done_dialog 2)")
(if s1
    (set_tile "k-d" (vl-prin1-to-string s1))
)
(setq id (start_dialog))
(unload_dialog dcl_id)
(cond ((= id 2)
         (if (setq s1 (car (entsel "选取一根曲线: ")))
         (c:tt)
         )
      )
)
(princ)
)
(defun popup (v /)
(cond ((= v "0") (set_tile "k-b" "1"))
      ((= v "1") (set_tile "k-b" "2"))
      ((= v "2") (set_tile "k-b" "3"))
)
)

aws 发表于 2024-7-27 13:07:43

请教大家,这是一个错误的程序,我想要实现这样的功能,请问怎么修改呢?

aws 发表于 2024-7-27 21:45:32

xyp1964 发表于 2024-7-27 21:39


感谢院长!又学到了

xyp1964 发表于 2024-7-27 21:57:48

(defun c:tt (/ Dlst ll1 ll2)
(defun main-pro () (princ))
(defun bu1 ()
    (if        (setq s1 (car (entsel "选取一根曲线: ")))
      (setq k-d (vl-prin1-to-string s1))
      (setq k-d "")
    )
    (sub)
)
(defun ak-a ()
    (xyp-Dcl-Gettile '("k-a"))
    (cond ((= k-a "0") (set_tile "k-b" "1"))
          ((= k-a "1") (set_tile "k-b" "2"))
          ((= k-a "2") (set_tile "k-b" "3"))
    )
)
(defun sub ()
    (setq ll1 '(k-a k-b k-d)
          ll2 '("0" "" "")
    )
    (xyp-initSet ll1 ll2)
    (setq lst1 '("钢铁" "玻璃" "木头")
          Dlst '(("k-a" "材料" "poplist" "lst1" "20" "(ak-a)")
               ("k-b" "属性" "str" "20")
               ("k-c" "拾取曲线" "button" "(bu1)")
               ("k-d" "图元名" "str" "20")
                )
    )
    (if        (= (xyp-Dcl-Init Dlst "【DCL练习】" t) 1)
      (main-pro)
    )
)
(sub)
(princ)
)

gble119 发表于 2024-7-28 19:48:39

多谢分享学习了
页: [1]
查看完整版本: 关于dcl控件动作触发问题