AutoLISP: Adding A Suffix to Layer Names

To go along with the previous post which adds a Prefix to layer names, this one allows you to add a suffix to layer names.

Here’s How:

  • RL2 <enter> to start
  • Enter text string to be added to the end of the layer names (My example was -2011 to show what layers were drawn in 2011)

;This routine will place a Suffix at the end of all Layer names and rename them.

;Of course, it will not rename Layer "0" or "Defpoints".

(prompt "\nType RL2 to run.........")

(defun C:RL2 ( / acadDocument theLayers layName pre)

(vl-load-com)

(setq pre (getstring "\nEnter Layer Suffix : "))

(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 layName pre))

) ;if

);defun

(princ)


Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Customization, Layers, Modifying, TIPS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s