ali888 Posted May 15, 2007 Posted May 15, 2007 Hi again, I have another question to ask. unsure if anyone has done this before. I have layers that i'd like to change or rename. It'd be too much work if i do it one by one. I was thinking if there is a program or coding to do that for AutoCAD 2005. Thank you in advance Quote
CarlB Posted May 15, 2007 Posted May 15, 2007 Have you tried the "rename" command? It allows use of wildcards, which may allow you to reduce the number of steps. Quote
mdbdesign Posted May 15, 2007 Posted May 15, 2007 You can use codes to do it but still got to type: name, chose color, linetype... It is easy in Layer Property Manager. Try this. Or import your own layer set, but still got to create... Quote
kchenault Posted January 12, 2010 Posted January 12, 2010 The RENAME command only seems to work for prefixes not suffixes. If it comes at the beginning of a layer name, great. If not, you are out of luck, it won't rename. Quote
rkent Posted January 12, 2010 Posted January 12, 2010 The RENAME command only seems to work for prefixes not suffixes. If it comes at the beginning of a layer name, great. If not, you are out of luck, it won't rename. You are responding to an old post, but you can rename prefix or suffix on layer names. EX. M-DETL-0001, M-DETL-0002, ... RENAME M-DETL-???? TO M-DETL-????-A Quote
kchenault Posted January 12, 2010 Posted January 12, 2010 I realized that it was old, but as I was looking for a solution to batch renaming, these types of threads keep coming up. I have been trying to rename multiple layers such as: *-DEMO to *-DEMO-ALT and it does not work. I have never been able to get the rename command to rename multiple layers by adding a suffix. If someone knows the answer, please let me know. Quote
lpseifert Posted January 12, 2010 Posted January 12, 2010 not a whole lot of testing so be careful (defun C:test ( / aDoc lyrs lyr-name suf) (vl-load-com) (setq fil (strcase (getstring "Enter filter: ")));don't forget the wildcard(s) (setq suf (getstring "Enter suffix: ")) (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (setq lyrs (vla-get-layers aDoc)) (vlax-map-collection lyrs 'lyr-add) (princ) );defun (defun lyr-add (lyr) (setq lyr-name (strcase (vlax-get-property lyr 'Name))) (if (wcmatch lyr-name fil) (vla-put-Name lyr (strcat lyr-name suf)) ) ;if (princ) );defun Quote
David Bethel Posted January 12, 2010 Posted January 12, 2010 A type of merge could also work. Edit the laylist to meet your needs: (defun c:mergel (/ vlist laylist ss tdef fe fd el) (setq vlist '(("ELEVATION" . 0) ("THICKNESS" . 0) ("CELTSCALE" . 1) ("CECOLOR" . "BYLAYER") ("CELTYPE" . "BYLAYER"))) (foreach v vlist (and (getvar (car v)) (setvar (car v) (cdr v)))) (setq laylist '(("OLD-LAYER" . "NEW-LAYER") ("3D-SZG" . "SNEEZE"))) (command "_.LAYER") (foreach l laylist (if (not (tblsearch "LAYER" (cdr l))) (command "_New" (cdr l)))) (command "") (foreach l laylist (and (setq ss (ssget "X" (list (cons 8 (car l))))) (command "_.CHPROP" ss "" "_LA" (cdr l) ""))) (while (setq tdef (tblnext "BLOCK" (not tdef))) (setq fe (cdr (assoc -2 tdef))) (entmake tdef) (while fe (setq fd (entget fe) el (cdr (assoc 8 fd))) (if (assoc el laylist) (setq fd (subst (cons 8 (cdr (assoc el laylist))) (assoc 8 fd) fd))) (entmake fd) (setq fe (entnext fe))) (entmake (list (cons 0 "ENDBLK")(cons 8 "0")))) (prin1)) -David Quote
kchenault Posted January 12, 2010 Posted January 12, 2010 Thanks people. I will try them out and let you know how they work. Quote
kchenault Posted January 13, 2010 Posted January 13, 2010 lpseifert your lisp routine worked perfectly. It did exactly what I was trying to get rename to do, but couldn't. I wish my lisp skills were to that level, alas they are not. You should show the folks at Autodesk a thing or two about what their routine could be doing. You rock! Thanks a million. Quote
lpseifert Posted January 13, 2010 Posted January 13, 2010 You know that adage about blind squirrels and nuts... Quote
lpseifert Posted January 13, 2010 Posted January 13, 2010 http://www.flipkart.com/even-blind-squirrel-finds-nut/1606045822-ktx3fu9uvd Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.