- (defun c:TT (/ DOC LayLst SS i obj Lay LayOpen)
- (if (null vlax-dump-object) (vl-load-com));;将Visual LISP扩展功能加载到AutoLISP
- (setq DOC (vla-get-activedocument (vlax-get-acad-object))
- LayLst (vla-get-layers DOC)
- )
- (defun *error* (Msg)
- (vla-endundomark DOC)
- )
- (while (eq 8 (logand 8 (getvar 'undoctl)))
- (vla-endundomark DOC)
- ) ;关闭以前的编组
- (vla-startundomark DOC) ;记录编组
- (if
- (and
- (princ "\n——★★★ 请选择需要保留图层的对象 ★★★——\n")
- (setq SS (ssget))
- )
- (progn
- (vlax-for XX LayLst (vla-put-layeron XX :vlax-false)) ;图层全关
- (repeat (setq i (sslength SS))
- (setq obj (vlax-ename->vla-object (ssname SS (setq i (1- i))))
- Lay (vla-get-Layer obj)
- )
- (if (not (vl-position Lay LayOpen))
- (progn
- (vla-put-layeron (vla-item LayLst Lay) :vlax-true) ;打开目标图层
- (setq LayOpen (cons Lay LayOpen))
- )
- )
- );关闭其它
- (setvar "CLAYER" (car LayOpen)) ;图层置为当前
- (princ "\n——★★★ 已关闭除所选对象以外的其它图层 ★★★——\n")
- )
- )
- (vla-endundomark DOC) ;结束编组
- (command "redraw")
- (princ)
- )
|