T704 Posted June 2, 2011 Posted June 2, 2011 Hey folks, can someone plz help me, i was trying to use the rename command to subtract a prefix (from my layer names) and i am unable to figure it out or does someone know of a lisp file that would enable me to delete a prefix or ad a suffix, is there one out there? Appreciate any and all comments... Thanks buddies Quote
Lee Mac Posted June 2, 2011 Posted June 2, 2011 Quick 'n Dirty: (defun c:DeleteLayerPrefix ( / p x n ) (vl-load-com) (if (< 1 (setq x (strlen (setq p (strcat (strcase (getstring t "\nSpecify Prefix: ")) "*"))))) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (wcmatch (strcase (setq n (vla-get-name l))) p) (vl-catch-all-apply 'vla-put-name (list l (substr n x))) ) ) ) (princ) ) Quote
T704 Posted June 2, 2011 Author Posted June 2, 2011 Lee thanks will give it a quick spin. thanks once again Quote
T704 Posted June 2, 2011 Author Posted June 2, 2011 Down and dirty gets the job done thanks, Lee !! Quote
Lee Mac Posted June 2, 2011 Posted June 2, 2011 Cool A whole set... (defun c:DeleteLayerPrefix ( / p x n ) (vl-load-com) (if (< 1 (setq x (strlen (setq p (strcat (strcase (getstring t "\nSpecify Prefix: ")) "*"))))) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (wcmatch (strcase (setq n (vla-get-name l))) p) (vl-catch-all-apply 'vla-put-name (list l (substr n x))) ) ) ) (princ) ) (defun c:DeleteLayerSuffix ( / s x n ) (vl-load-com) (if (< 1 (setq x (strlen (setq s (strcat "*" (strcase (getstring t "\nSpecify Suffix: "))))))) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (wcmatch (strcase (setq n (vla-get-name l))) s) (vl-catch-all-apply 'vla-put-name (list l (substr n 1 (- (strlen n) x -1)))) ) ) ) (princ) ) (defun c:AddLayerPrefix ( / p w n ) (vl-load-com) (setq p (getstring t "\nSpecify Prefix: ") w (strcat (strcase p) "*")) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (not (wcmatch (strcase (setq n (vla-get-name l))) w)) (vl-catch-all-apply 'vla-put-name (list l (strcat p n))) ) ) (princ) ) (defun c:AddLayerSuffix ( / s w n ) (vl-load-com) (setq s (getstring t "\nSpecify Suffix: ") w (strcat "*" (strcase s))) (vlax-for l (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (not (wcmatch (strcase (setq n (vla-get-name l))) w)) (vl-catch-all-apply 'vla-put-name (list l (strcat n s))) ) ) (princ) ) Quote
T704 Posted June 2, 2011 Author Posted June 2, 2011 Thanks Lee over and above thank you this will be part of my LEEMAC arsenal. much appreciated! 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.