I am working on updating my office standards. One issue that has arisen is that many of the layer names have been written ALL CAPS and many of them have been written in Title Case. I would like to change them all to be Title Case. Unfortunately the layer translator and even the AutoCAD Standards system doesn't seem to recognize case. I need to update the Template Project and so will be editing the layer names to nearly 100 files with some 50 or so layer names to be edited in each file... Re-typing 5,000 layer names is certainly doable but does anyone know of an easier way?
This should work. Save the attached file in a trusted path. Load it with (load (findfile "titlelayers.lsp")). Run with the command TITLELAYERS.
The contents are illustrated below, if interested:
;;D. C. Broad, Jr. 2014 ;;Convert a string to title case (defun tcase (str / mid) (vl-list->string (mapcar '(lambda (x) (cond ((= x 32) (setq mid nil) x) ((and (not mid) ;first character (< 96 x 123) ;alphabetic ) (setq mid t) (- x 32)) (t x))) (vl-string->list (strcase str t))))) ;;Main function. Switch all layer names to title case ;;D. C. Broad, Jr. 2014 (defun c:titlelayers () (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (vla-put-name lay (tcase (vla-get-name lay)))) )
Thanks for the effort. It sorta works, but doesn't. For example, standard office policy is to have model space layers denoted by 'A-' and then the object name. For example A-Wall or A-Door. That Lisp changes the layer name to A-wall and A-door. There are other examples that probably would be even more tricky like the paper-space layers which are named as PS-Text or PS-Dimensions.
As far as using the layer translator to make a character change and then use it again to change the character AND the case to be what is desired, that does not seem to work either at least not for a whole lot of layers. I wanted to change A-DOOR to A-Door and so mapped it to change to A-Doo. It created the layer A-Doo along with keeping the layer A-DOOR and left all the items on A-DOOR. Doh and Doo...
Here is a revision that works with most situations. For a heavily customized routine, I can give you a price (not free). Send me a private message if interested in employing my services.