试试这个:
- ; w ~ layer name
- ; x ~ colour
- ; y ~ linetype
- ; z ~ lineweight
- (defun c:test (/ *error* varlist oldvars)
- (defun *error* (msg)
- (mapcar 'setvar varlist oldvars)
- (if (= msg "")
- (princ "\nFunction Complete.")
- (princ "\nError or Esc Pressed.")
- ) ;_ end if
- (princ)
- ) ;_ end defun
- (setq varlist (list "CMDECHO" "CLAYER")
- oldvars (mapcar 'getvar varlist)
- ) ;_ end setq
- (setvar "cmdecho" 0)
- (defun chnglay (w x y z)
- (if (not (tblsearch "Layer" w))
- (command "-layer" "m" w "c" x w "lt" y w "lw" z w "")
- (command "-layer" "c" x w "lt" y w "lw" z w "")
- ) ;_ end if
- (princ)
- ) ;_ end defun
- (defun GetLayerList ()
- (vl-load-com)
- (vlax-for l
- (vla-get-Layers
- (vla-get-ActiveDocument
- (vlax-get-acad-object)
- ) ;_ end vla-get-ActiveDocument
- ) ;_ end vla-get-Layers
- (setq oLst
- (cons (vla-get-Name l) oLst)
- ) ; end setq
- ) ; end vlax-for
- (reverse oLst)
- ) ; end of GetLayerList
- (GetLayerList)
- (if (= oLst nil)
- (alert "No Layers Retrieved.")
- ) ;_ end if
- [b][color=Red](foreach lay oLst
- (if (wcmatch lay "wat*")
- (chnglay lay "2" "Hidden" "1.5")
- ) ;_ end if
- ) ;_ end foreach[/color][/b]
- (*error* "")
- (princ)
- ) ;_ end defun
添加额外代码,如为不同的通配符匹配突出显示的代码。 |