wxa123wl 发表于 2019-9-16 19:47:38

自定义工具箱对话框

我的工具箱命令是ZZ比如里有个工具 的名利是zz-pldy,,我运行了一次再回车,他又运行zz了,可以直接用运行我上次运行的那个那个命令吗?求修改一下


[*](defun Dcl-ButtonM (titl buttons flag helpstr / a b c)
[*](or (and helpstr (/= helpstr "")) (setq helpstr 00))
[*](defun strsplist (str / i)
[*]    (if (setq i (vl-string-search " " str))
[*]      (list (substr str 1 i)
[*]            (vl-string-trim " " (substr str (+ 2 i)))
[*]      )
[*]    )
[*])
[*](defun makedcl (str_lst / fileID dclHandle)
[*]    (setq dclfile (vl-filename-mktemp nil nil ".dcl")
[*]          fileID(open dclfile "w")
[*]    )
[*]    (cond ((= (type str_lst) 'str) (write-line str_lst fileID))
[*]          ((= (type str_lst) 'list)
[*]         (foreach n str_lst (write-line n fileID))
[*]          )
[*]    )
[*]    (close fileID)
[*]    (setq dclHandle (load_dialog dclfile))
[*])
[*](setq b (if flag
[*]            ":column{ label = \""
[*]            ":row{children_alignment = top ;\n
[*]children_fixed_height = true ;\n label = \""
[*]          )
[*]      c (if flag
[*]            ":row{children_alignment = top ;\n
[*]children_fixed_height = true ;\nlabel = \""
[*]            ":column{label = \""
[*]          )
[*]      d '("ESC")
[*]      a (strcat (vl-string-translate
[*]                  "$~"
[*]                  "AB"
[*]                  (vl-filename-base (vl-filename-mktemp))
[*]                  )
[*]                  ":dialog{label=\""
[*]                  titl
[*]                  "\";\n"
[*]                  b
[*]                  "\";\n"
[*]          )
[*])
[*](foreach x buttons
[*]    (if (listp x)
[*]      (progn
[*]      (setq a (strcat a c (car x) "\";\n"))
[*]      (foreach y (last x)
[*]          (setq b (strsplist y)
[*]                a (if b
[*]                  (strcat a
[*]                            ":button {key =\""
[*]                            (car b)
[*]                            "\";label=\""
[*]                            (last b)
[*]                            "\";"
[*]                            (if (= (substr (car b) 1 1) "~")
[*]                              "is_enabled = false ;"
[*]                              "\n"
[*]                            )
[*]                            "}\n"
[*]                  )
[*]                  (strcat a "spacer_0;\n")
[*]                  )
[*]                d (if (/= (car b) nil)
[*]                  (cons (car b) d)
[*]                  d
[*]                  )
[*]          )
[*]      )
[*]      (setq a (strcat a "}\n"))
[*]      )
[*]      (setq a (strcat a "spacer_0;\n"))
[*]    )
[*])
[*](setq d    (cdr (REVERSE d))
[*]      a    (strcat
[*]               a
[*]               (if flag
[*]               "} spacer_1;:row"
[*]               "} spacer_1;:row"
[*]               )
[*]               "{alignment = centered ;fixed_width = true ;
[*]spacer_0;:button{fixed_width = true ;width = 4 ;key = \"help\";label = \" 帮助 \";}\n"
[*]               ":button{fixed_width = true ;width = 4 ;key=\"cancel\";label=\" 取消 \";
[*]is_cancel = true;is_default = true;}}}"
[*];;;         "{alignment = centered ;\n fixed_width = true ; \n spacer_0;\n cancel_button; \n
[*];;;         :text{fixed_width = true ; \n width = 2;\n } \n help_button;}}"
[*];;;          "{alignment = centered ; \n fixed_width = true ;\n help_button; \n :text{fixed_width = true ; \n width = 2;\n } \n cancel_button;}}"
[*]             )
[*]      dcl(makedcl a)
[*]      lst1 '()
[*]      i    1
[*])
[*](foreach key d
[*]    (setq tx   (strcat "(action_tile \""
[*]                     key
[*]                     "\"\"(done_dialog "
[*]                     (itoa i)
[*]                     ")\")"
[*]               )
[*]          lst1 (cons tx lst1)
[*]          i    (1+ i)
[*]    )
[*])
[*](new_dialog (substr a 1 8) dcl)
[*](action_tile "cancel" "(done_dialog 0)")
[*](action_tile "help" "(alert helpstr)")
[*](eval (read (strcat "(progn" (apply 'strcat lst1) ")")))
[*](setq ctl (start_dialog))
[*](UNLOAD_DIALOG dcl)
[*](vl-file-delete dclfile)
[*](if (/= ctl 0)
[*]    (progn
[*]      (setq cmds (nth (- ctl 1) d))
[*]      ;;检查命令是否~开头,有就去掉,如果运行中没有更改该命令button的enable值,这句可以不要
[*]      (if (= (substr cmds 1 1) "~")
[*]      (setq cmds (substr cmds 2 (1- (strlen cmds))))
[*]      )
[*]      ;;
[*];;;    (cond
[*];;;      ((or(= (eval (read (strcat "(type c:" cmds ")"))) 'SUBR)
[*];;;      (= (eval (read (strcat "(type c:" cmds ")"))) 'USUBR))
[*];;;       (princ "\n")
[*];;;      (eval (read (strcat "(c:" cmds ")"))))
[*];;;      ((or(= (eval (read (strcat "(type " cmds ")"))) 'SUBR)
[*];;;      (= (eval (read (strcat "(type " cmds ")"))) 'USUBR))
[*];;;       (princ "\n")
[*];;;      (eval (read (strcat "(" cmds ")"))))
[*];;;      (t (princ "\n")(vl-load-com)(vl-cmdf cmds))
[*];;;    )
[*]                                        ;设置未知命令反应器
[*]      (if (= sk-rctCmds nil)
[*]      (setq sk-rctCmds
[*]               (vlr-command-reactor
[*]               nil
[*]               '((:vlr-unknownCommand . sk-cmdunknown))
[*]               )
[*]      )
[*]      (vlr-add sk-rctCmds)
[*]      )
[*]                                        ;新的命令判断方式,代码更短
[*]      (cond
[*]      ((boundp (read (strcat "c:" cmds)))
[*]         (princ "\n")
[*]         (eval (read (strcat "(c:" cmds ")")))
[*]      )
[*]      ((boundp (read cmds))
[*]         (princ "\n")
[*]         (eval (read (strcat "(" cmds ")")))
[*]      )
[*]      (t (princ "\n") (vl-load-com) (vl-cmdf cmds))
[*]      )
[*]    )
[*])
[*])
[*]
[*];;反应器回调函数
[*](defun sk-cmdunknown (param1 param2)
[*](princ "!!!!未知命令或命令或开发中!!!!")
[*](vlr-remove sk-rctCmds)
[*])
[*]
[*]
[*](defun c:ZZ (/ lst)
[*](setq      lst '(("批量系列"
[*]                     ("ZG-PLDY 批量打印" "ZG-PUU2 批量清理")
[*]                     )
[*]
[*]
[*]                      ("通用系列"
[*]                        ("ZG-SSS 选择相同" "ZG-AR1 动态矩阵" "ZG-JDFZ 角点复制" "ZG-TAS 图案刷" "ZG-ZBGL 坐标归零""ZG-WLK 生外轮廓" "ZG-EXPLODE10 分解10次")
[*]                      )
[*]
[*]
[*]
[*]
[*]
[*]
[*]                  )
[*])
[*](Dcl-ButtonM "常用批量" lst nil helpstr)
[*];    (Dcl-ButtonM "【度之工具】V2015.8.19" lst t nil)    加t 面板为横向排列
[*](princ)
[*])

言戲無軍 发表于 2019-9-25 23:36:11

如果方便可以把明经币改为红包可联系qq 344549985 帮你解决

sharetow 发表于 2019-12-11 22:53:09

写个快捷键面板吧,比你这样老开工具箱面板的绘图效率高。

caiqs 发表于 2019-12-19 20:52:02

逻辑有问题,假如你再次输入zz想变成zz-pldy,那你怎么调用你的原来ZZ应该有的功能打开工具箱?

ketxu 发表于 2020-1-5 00:59:40

Thanks for sharing ^^
页: [1]
查看完整版本: 自定义工具箱对话框