Give this a try...
- ;;; Add Prefix and/or Suffix to all layers (excluding 0, Defpoints and XRef layers;;; #Prefix - Prefix string to append to layer names (nil for nothing);;; #Suffix - Suffix string to append to layer names (nil for nothing);;; Alan J. Thompson, 02.16.10(defun LayerPrefixSuffix (#Prefix #Suffix / #Prefix #Suffix) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) (and (or (and (not #Prefix) (setq #Prefix "")) (snvalid #Prefix) (setq #Prefix "")) (or (and (not #Suffix) (setq #Suffix "")) (snvalid #Suffix) (setq #Suffix "")) (progn (vlax-for x (vla-get-layers *AcadDoc*) (or (wcmatch (strcase (vla-get-name x)) "*|*,0,DEFPOINTS") (vl-catch-all-apply 'vla-put-name (list x (strcat #Prefix (vla-get-name x) #Suffix))) ) ;_ or ) ;_ vlax-for T ) ;_ progn ) ;_ and) ;_ defun
Example:
- (LayerPrefixSuffix "Begin-" "-End")
It will allow you to add a prefix and/or a suffix. Works on locked layers and ignores the 0, Defpoints and XRef layers. |