本帖最后由 作者 于 2009-2-4 21:25:47 编辑
caoyin发表于2008-12-6 13:23:00;;选择对象 entsel ssget等 函数扩展;; by caoyin @mjtd.com;;____________________________________________________________________________________________________;; ▓ (lt:entsel msg ;;____________________________________________________________________________________________________
;; ▓ (lt:ssget-for msg flt fun)
;; [功能] 获取选择集并实时进行指定函数的操作
;; [参数] msg---提示信息(STR),如果nil时则显示缺省为"\n选择对象: "
;; flt---等同于 ssget 函数图元过滤表
;; fun---要对所选对象执行的函数
;; [返回] 成功->选择集,反之->nil
;| [测试]
(lt:ssget-for "\n删除对象:" nil 'entdel)
(defun c:tt ()
(lt:ssget-for "选择要改变颜色的直线:"
'((0 . "line"))
'(lambda (x)
(if (or (>= col 256) (not col)) (setq col 0))
(vla-put-color (vlax-ename->vla-object x) (setq col (1+ col)))
)
)
)
|;- (defun lt:ssget-for (msg flt fun / cme nom sp ss ss2 e)
- (setq cme (getvar "cmdecho")
- nom (getvar "nomutt")
- )
- (if msg
- (setq msg (strcat "\r" msg))
- (setq msg "\r选择对象: ")
- )
- (setvar "nomutt" 1)
- (setvar "cmdecho" 0)
- (while
- (progn
- (setq sp (ssget "_P"))
- (princ msg)
- (command "_.select" "_si")
- (command pause)
- (setq ss (ssget "_p"))
- (if (and sp (equal (ssnamex sp) (ssnamex ss)))
- (setq ss nil)
- )
- ss
- )
- (if (and ss (setq ss (ssget "_p" flt)))
- (progn
- (if (not ss2) (setq ss2 (ssadd)))
- (repeat (setq n (sslength ss))
- (setq e (ssname ss (setq n (1- n))))
- (if fun (apply fun (list e)))
- (ssadd e ss2)
- )
- )
- )
- )
- (setvar "cmdecho" cme)
- (setvar "nomutt" nom)
- ss2
- )
;;下面一个函数源自 xdcad.net 网友 讨论,龙版主发过,为了方便整理,放于此处
;;____________________________________________________________________________________________________
;; ▓ (lt:ssget lst)
;; [功能] 获取选择集(类似于 ssget 函数,不同的是可以加入提示信息)
;; [参数] lst----(LIST)参数列表,包含若干元素:
;; 第一个元素----提示信息(STR),如果nil时则显示缺省为"\n选择对象: "
;; 其他元素------包括 ssget 函数的所有参数
;; [返回] 成功->选择集,反之->nil
;; [测试] (lt:ssget '("\n选择直线或圆弧: " ((0 . "line,arc"))))
;; (lt:ssget '(nil "_x" ((0 . "line,arc"))))- (defun lt:ssget (lst / oldnom ss)
- (if (setq msg (car lst))
- (progn
- (setq oldnom (getvar "nomutt"))
- (princ msg)
- (setvar "nomutt" 1)
- )
- )
- (setq ss (vl-catch-all-apply 'ssget (cdr lst)))
- (if oldnom (setvar "nomutt" oldnom))
- (if (not (vl-catch-all-error-p ss)) ss)
- )
|