- 积分
- 15151
- 明经币
- 个
- 注册时间
- 2008-8-21
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2011-7-19 12:50:04
|
显示全部楼层
本帖最后由 690994 于 2011-7-19 12:55 编辑
这个我早就用上了,我的处理和你有点不同,我主要是用在数字图层开启/改线型比例/颜色/倒角等
但不能处理未知命令的提示,不够完美,另外按空格不能重复这种命令。
我的返回代码处理部分如下(Samxxx是我的自定义函数):
(defun unknownCommand (calling-reactor commandInfo / c n *doc*)
(setq *doc* (vla-get-ActiveDocument (vlax-get-acad-object))
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))))
)
(cond
((or(wcmatch c "0,200,201,255,256")
(and(wcmatch c "##")(wcmatch c "~0#"))
)
(vla-sendcommand *doc* (strcat"(sam_activelayer \""(vl-princ-to-string c)"\") "))
)
((wcmatch c "[1-9],###,####,#####,######,#######,########")
(if(= c "345")(setq c "12345"))
(if(= c "678")(setq c "6789"))
(vla-sendcommand *doc* (strcat "(sam_onlayer \"" (vl-princ-to-string c)"\") "))
)
((and(=(substr c 1 1) "O")
(numberp (setq n(read(substr c 2))))
(>= n 10.0)
)
(vla-sendcommand *doc* (strcat "(sam_laycopy \"" (vl-princ-to-string n) "\") "))
)
((and(=(substr c 1 1) "M")
(numberp (setq n(read(substr c 2))))
(>= n 10.0)
)
(vla-sendcommand *doc* (strcat "(sam_laymove \"" (vl-princ-to-string n) "\") "))
)
((and(=(substr c 1 1) "F")
(numberp (setq n(read(substr c 2))))
)
(vla-sendcommand *doc* (strcat "(sam_fillet " (vl-princ-to-string n) " nil) "))
)
((and(=(substr c 1 1) "C")
(numberp (setq n(read (substr c 2))))
)
(vla-sendcommand *doc* (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)
(vla-sendcommand *doc* "(Sam_co_lts nil nil) ")
(vla-sendcommand *doc* (strcat "(Sam_co_lts " (vl-princ-to-string (fix n)) " nil) "))
)
)
((and(=(substr c 1 1) "L")
(numberp (setq n (read (substr c 2))))
)
(vla-sendcommand *doc* (strcat "(Sam_co_lts nil " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "X")
(numberp (setq n(read(substr c 2))))
)
(vla-sendcommand *doc* (strcat "(sam_xline " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "D")
(numberp (setq n(read(substr c 2))))
)
(vla-sendcommand *doc* (strcat "(sam_dimbit " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "H")
(numberp (setq n(read(substr c 2))))
)
(vla-sendcommand *doc* (strcat "(sam_ha_sc " (vl-princ-to-string n) ") "))
)
((and(=(substr c 1 1) "T")
(numberp (setq n(read(substr c 2))))
)
(vla-sendcommand *doc* (strcat "(sam_text_h " (vl-princ-to-string n) ") "))
)
)
(princ)
)
用vla-sendcommand 就是下面两行提示不能消除不够完美。
命令: l0 未知命令“L0”。按 F1 查看帮助。
命令: (Sam_co_lts nil 0)
|
|