Jump to content

Recommended Posts

Posted

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

Posted

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)
)

Posted

Lee thanks will give it a quick spin. thanks once again

Posted

Down and dirty gets the job done thanks, Lee !!

Posted

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)
)

Posted

Thanks Lee over and above thank you this will be part of my LEEMAC arsenal. much appreciated!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...