AutoCAD Architecture Forum
Welcome to Autodesk’s AutoCAD Architecture Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing Case of Layer Names

5 REPLIES 5
Reply
Message 1 of 6
Libbya
1068 Views, 5 Replies

Changing Case of Layer Names

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?

5 REPLIES 5
Message 2 of 6
David_W_Koch
in reply to: Libbya

My experience, editing one at a time, is that if the only change you make to a layer name is the case, that change will not stick. To make the change stick, I have had to make some other change as well (such as adding a character), and then edit it again to remove the additional change.

David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

Message 3 of 6
dbroad
in reply to: Libbya

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

 

 

 

Architect, Registered NC, VA, SC, & GA.
Message 4 of 6
Libbya
in reply to: dbroad

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

Message 5 of 6
dbroad
in reply to: Libbya

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.

 

 

Architect, Registered NC, VA, SC, & GA.
Message 6 of 6
Libbya
in reply to: dbroad

Wow, very cool.  I'll definitely keep in mind your services.  Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost