明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: gbhsu

cmd+num 命令简称加任意数字组成智能命令[07.20]

    [复制链接]
发表于 2011-7-19 09:39 | 显示全部楼层
好帖,下载以后再好好研究
发表于 2011-7-19 12:50 | 显示全部楼层
本帖最后由 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)

 楼主| 发表于 2011-7-19 13:10 | 显示全部楼层
回复 690994 的帖子

关于命令不能重复我正在思考,
至于消除“未知命令问题”超出本人能力之外,呵呵,吾亦不能也!
等下更新功能,欢迎大家继续关注!
发表于 2011-7-19 14:15 | 显示全部楼层
一个大而全的程序不容易做好,因为要包罗万象,要照顾不同绘图习惯。只能说,适用于自己的就是好程序。如果获得大多人的好评,就是好的程序。谢谢了。
发表于 2011-7-19 15:06 | 显示全部楼层
谢谢楼主的分享
先下载收藏看看,学习领会。
谢谢
发表于 2011-7-20 10:55 | 显示全部楼层
很好的程式,学习中
发表于 2011-7-20 12:53 | 显示全部楼层
昨天准备回复 此帖必火.
今天再回都晚了,已经火了.
发表于 2011-7-20 12:54 | 显示全部楼层
牛逼的贴呀
 楼主| 发表于 2011-7-20 13:04 | 显示全部楼层
回复 LLXXZZ 的帖子

我也意想不到呀,
主要是为了大家作想,
减少绘图过程中的繁琐步骤!
感谢大家的支持,
继续深化中!
发表于 2011-7-20 13:55 | 显示全部楼层
楼主很强悍!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-25 14:31 , Processed in 0.847584 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表