Hi wwydock,
quick and dirty:
(vl-load-com)
(defun c:demo (/ pref) (if (and (setq pref (getstring T "\nEnter layer prefix: ")) (/= pref "") ) (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object) ) ) (if (wcmatch (vla-get-name layer) "*pipe*") (vl-catch-all-apply 'vla-put-name (list layer (strcat pref (vla-get-name layer))) ) ) ) ) (princ) )
Hope that helps
Henrique
slightly modify the line in which layer name is checked as like below: It will work.
(if (wcmatch (strcase (vla-get-name layer)) "*PIPE*")
regards,
gsktry
If the target is to add a prefix to the layer name as long as it contains "pipe",
You can just use RENAME command, no need an add-on, as shown below:
Just download my free Layer Apps from Exchange store
Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales |Exchange App Store
Hi wwydock,
I would suggest you to visit this page:
http://www.cadforum.cz/cadforum_en/download.asp?fileID=1857
It points to a .vlx file page download: the program is named Rrename and it lets you rename layers, layouts, linetypes and blocks using prefixes and suffixes.
I had the same problem as you and that program solved it.
I didn't try it on multiple files: don't know if it will work, but maybe a little script will help.
Hope this helps you.
Giancarlo
Another, for Vanilla AutoLISP:
(defun c:prelay ( / d e l p ) (if (/= "" (setq p (getstring t "\nSpecify prefix: "))) (while (setq d (tblnext "layer" (null d))) (setq l (cdr (assoc 2 d))) (if (and (wcmatch (strcase l) "*PIPE*") (not (wcmatch (strcase l) (strcat (strcase p) "*")))) (setq e (entget (tblobjname "layer" l)) e (entmod (subst (cons 2 (strcat p l)) (assoc 2 e) e)) ) ) ) ) (princ) )