This routine is a great little routine that allows you to add a prefix to all layer names. Although, It does not allow you add a prefix that already exists in at least one layer name like “A-.” I will try to tweak that in the future.
RL <enter> to Rename Layer by adding a prefix
Enter the new Prefix (for my example, since I work for an Audio-Visual company, I added “AV-” to my layers)
;This routine will place a Prefix in front of all Layer names ;and rename them. ;Of course, it will not rename Layer "0" or "Defpoints". (prompt "\nType RL to run.........") (defun C:RL ( / acadDocument theLayers layName pre) (vl-load-com) (setq pre (getstring "\nEnter Layer Prefix : ")) (setq acadDocument (vla-get-activedocument (vlax-get-acad-object))) (setq theLayers (vla-get-layers acadDocument)) (vlax-map-collection theLayers 'layer-mod) (princ) );defun (defun layer-mod (theLayer) (setq layName (vlax-get-property theLayer 'Name)) (if (not (member layName '("0" "Defpoints"))) (vla-put-Name thelayer (strcat pre layName)) ) ;if );defun (princ)
Pingback: AutoLISP: Add A Prefix To Layer Names – map4bd