- 积分
- 15151
- 明经币
- 个
- 注册时间
- 2008-8-21
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2011-9-21 10:12:12
|
显示全部楼层
gbhsu 发表于 2011-9-20 21:47
没看到你的源码,这样做每次可能还要出现未知命令的提示
我是将未知命令重新定义成命令,可能是繁了点, ...
我以前也是将自己常用的定义成命令,但这样还是不够用,
全部定义又太多命令了,不知会不会影响速度。
至于未知命令提示还是不能消除,好象是CAD判断是未知命令
后才会执行我们定义的程序。好象在论坛看到有个变量能控制
SSGET不显示请选择实体提示的,对这个不知有没在效。
这个不影响使用,我也就懒得试了。
我的代码如下,samcom对应内容是我自己定义的功能。
(defun unknownCommand (calling-reactor commandInfo / c n)
(setq c (strcase (car commandInfo)))
(if (and(setq n(vl-string-search "." c))(wcmatch(substr c n 1) "[A-Z]")) ;f.5>F0.5
(setq c (strcat(substr c 1 n)"0"(substr c (1+ n))))
)
(setq n t)
(cond
((or(wcmatch c "0,200,201,255,256")
(and(wcmatch c "##")(wcmatch c "~0#"))
)
(setq samcom(strcat"(sam_activelayer \""(vl-princ-to-string c)"\") "))
)
((wcmatch c "[1-9],###,####,#####,######,#######,########")
(if(= c "345")(setq c "12345"))
(if(= c "678")(setq c "6789"))
(setq samcom(strcat "(sam_onlayer \"" (vl-princ-to-string c)"\") "))
)
((and(=(substr c 1 1) "O")
(numberp (setq n(read(substr c 2))))
(>= n 10.0)
)
(setq samcom(strcat "(sam_laycopy \"" (vl-princ-to-string n) "\") "))
)
((and(=(substr c 1 1) "M")
(numberp (setq n(read(substr c 2))))
(>= n 10.0)
)
(setq samcom(strcat "(sam_laymove \"" (vl-princ-to-string n) "\") "))
)
((and(=(substr c 1 1) "F")
(numberp (setq n(read(substr c 2))))
)
(setq samcom(strcat "(sam_fillet " (vl-princ-to-string n) " nil) "))
)
((= c "FF")
(setq samcom "(sam_fillet 0.0 nil) ")
)
((and(=(substr c 1 1) "C")
(numberp (setq n(read (substr c 2))))
)
(setq samcom(strcat "(sam_fillet " (vl-princ-to-string n) " t) "))
)
((and(=(substr c 1 1) "N")
(numberp (setq n(read(substr c 2))))
)
(if(= n 0.0)
(setq samcom "(sam_co_lts nil nil) ")
(setq samcom(strcat "(sam_co_lts " (vl-princ-to-string (fix n)) " nil) "))
)
)
((and(=(substr c 1 1) "L")
(numberp (setq n (read (substr c 2))))
)
(setq samcom(strcat "(sam_co_lts nil " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "X")
(numberp (setq n(read(substr c 2))))
)
(setq samcom(strcat "(sam_xline " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "D")
(numberp (setq n(read(substr c 2))))
)
(setq samcom(strcat "(sam_dimbit " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "H")
(numberp (setq n(read(substr c 2))))
)
(setq samcom(strcat "(sam_ha_sc " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "T")
(numberp (setq n(read(substr c 2))))
)
(setq samcom(strcat "(sam_text_h " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "J")
(numberp (setq n(read(substr c 2))))
)
(setq samcom(strcat "(sam_jion_select " (vl-princ-to-string n) ") "))
)
(t (setq n nil))
)
(if n(vl-catch-all-apply 'vla-SendCommand (list(vla-get-ActiveDocument (vlax-get-acad-object)) "SmartCommand ")))
(princ)
)
(defun c:SmartCommand( / *doc* )
(vla-startundomark (setq *doc*(vla-get-activedocument (vlax-get-acad-object))))
(setvar "cmdecho" 0)
(if(and (=(type samcom) 'str)(wcmatch samcom "(sam_*\) "))
(vl-catch-all-apply 'eval (list (read samcom))))
(setvar "cmdecho" 1)
(vla-endundomark *doc*)
(princ)
)
|
评分
-
查看全部评分
|