zwqgdhl 发表于 2011-7-19 09:39:07

好帖,下载以后再好好研究

690994 发表于 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) "")) ;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 ",###,####,#####,######,#######,########")
      (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)

gbhsu 发表于 2011-7-19 13:10:44

回复 690994 的帖子

关于命令不能重复我正在思考,
至于消除“未知命令问题”超出本人能力之外,呵呵,吾亦不能也!
等下更新功能,欢迎大家继续关注!

xiaxiang 发表于 2011-7-19 14:15:11

一个大而全的程序不容易做好,因为要包罗万象,要照顾不同绘图习惯。只能说,适用于自己的就是好程序。如果获得大多人的好评,就是好的程序。谢谢了。

461045462 发表于 2011-7-19 15:06:07

谢谢楼主的分享
先下载收藏看看,学习领会。
谢谢

hhh454 发表于 2011-7-20 10:55:13

很好的程式,学习中

LLXXZZ 发表于 2011-7-20 12:53:14

昨天准备回复 此帖必火.
今天再回都晚了,已经火了.

wujingsongwangj 发表于 2011-7-20 12:54:43

牛逼的贴呀

gbhsu 发表于 2011-7-20 13:04:19

回复 LLXXZZ 的帖子

我也意想不到呀,
主要是为了大家作想,
减少绘图过程中的繁琐步骤!
感谢大家的支持,
继续深化中!

dinosaurhxe 发表于 2011-7-20 13:55:52

楼主很强悍!
页: 1 [2] 3 4 5 6 7 8 9 10 11
查看完整版本: cmd+num 命令简称加任意数字组成智能命令[07.20]