Jump to content

Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working


Recommended Posts

Posted

@Clint Please give it a try 

 

 

(defun c:lay-nam-to-capital (/  (ACAD-OBJ ADOC LAY-COLL))
  (VL-LOAD-COM)
  (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT))  
  (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) 
  (SETQ LAY-COLL (VLA-GET-LAYERS ADOC))
  (vlax-for lay	lay-coll
    (vla-put-name lay (strcase (vla-get-name lay)))
  ) ;_ end of vlax-for
) ;_ end of defun

 

  • Like 2
Posted
On 06/12/2025 at 15:56, Clint said:

My task is to hash out a program that reads from two lists and updates layer names to match the old version to both the current name (UPPERCASE).

 

If I getted correct, this can be accomplish, but you need to do a systematization in naming the layers. One of the approaches can be to make an .txt file in which you will store the systematizated layers (the proper order must be, for e.g. "Tropic,Train,Traffic" or "Tropic\n" "Train\n" "Traffic\n" etc. The \n means new line). Then, you will run the code from my post, get an list of layers inside the drawing, then select desired layers to matches with .txt  file from which you want to get a proper names (for e.g. in .txt file you have the layer name "TrAffiC", after choosing the layer "Traffic" in the drawing with "TrAffiC", you can substitued with proper name).

  • Like 1
Posted
6 hours ago, devitg said:

@Clint Please give it a try 

 

 

(defun c:lay-nam-to-capital (/  (ACAD-OBJ ADOC LAY-COLL))
  (VL-LOAD-COM)
  (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT))  
  (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) 
  (SETQ LAY-COLL (VLA-GET-LAYERS ADOC))
  (vlax-for lay	lay-coll
    (vla-put-name lay (strcase (vla-get-name lay)))
  ) ;_ end of vlax-for
) ;_ end of defun

 

 

 Yes, this will substitued all layers into the UPPERCASE.

  • Like 1
Posted
11 hours ago, devitg said:

@Clint Please give it a try 

 

 

(defun c:lay-nam-to-capital (/  (ACAD-OBJ ADOC LAY-COLL))
  (VL-LOAD-COM)
  (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT))  
  (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) 
  (SETQ LAY-COLL (VLA-GET-LAYERS ADOC))
  (vlax-for lay	lay-coll
    (vla-put-name lay (strcase (vla-get-name lay)))
  ) ;_ end of vlax-for
) ;_ end of defun

 

As @Clint ask for 

 

Quote

Force Existing Layer Names to UPPER CASE

 

  • Like 1
Posted

Yes, but as it for as Title name for the topic. The plot is different. 😅 So, you're code will certenatly accomplish the desired result. 👍

  • Like 1
Posted

I use the below code to force all layers to uppercase. I don't remember who wrote it but it is most appreciated:

;Change All Layer Names to Uppercase
(vl-load-com)
(vlax-map-collection
  (vla-get-layers
    (vla-get-activedocument
      (vlax-get-acad-object)
    )
  )
  '(lambda (x)
     (vla-put-name x (strcase (vla-get-name x)))
   )
)

(defun lva (/ kw kval doc adoc lao cnt inc cvprt blk pw)
;Put this lisp to Appload StartUp Suite
  (vl-load-com)
  (setq kval :vlax-true)
  (setq	doc  (vlax-get-object "AutoCad.Application")
	adoc (vla-get-ActiveDocument doc)
	lao  (vla-get-Layouts adoc)
	cnt  (vla-get-Count lao)
	inc  0
  )
  (repeat cnt
    (setq cvprt	(vla-Item lao inc)
	  inc	(+ inc 1)
	  blk	(vla-get-Block cvprt)
    )
    (vlax-for itm blk
      (if
	(vlax-property-available-p itm 'DisplayLocked)
	 (progn
	   (vla-put-DisplayLocked itm kval)
	   (vla-update itm)
	 )
      )
    )
  )
  (princ)
)

 

Posted
13 hours ago, troggarf said:

I use the below code to force all layers to uppercase. I don't remember who wrote it but it is most appreciated:

;Change All Layer Names to Uppercase
(vl-load-com)
(vlax-map-collection
  (vla-get-layers
    (vla-get-activedocument
      (vlax-get-acad-object)
    )
  )
  '(lambda (x)
     (vla-put-name x (strcase (vla-get-name x)))
   )
)

(defun lva (/ kw kval doc adoc lao cnt inc cvprt blk pw)
;Put this lisp to Appload StartUp Suite
  (vl-load-com)
  (setq kval :vlax-true)
  (setq	doc  (vlax-get-object "AutoCad.Application")
	adoc (vla-get-ActiveDocument doc)
	lao  (vla-get-Layouts adoc)
	cnt  (vla-get-Count lao)
	inc  0
  )
  (repeat cnt
    (setq cvprt	(vla-Item lao inc)
	  inc	(+ inc 1)
	  blk	(vla-get-Block cvprt)
    )
    (vlax-for itm blk
      (if
	(vlax-property-available-p itm 'DisplayLocked)
	 (progn
	   (vla-put-DisplayLocked itm kval)
	   (vla-update itm)
	 )
      )
    )
  )
  (princ)
)

 

Hi @troggarf

 

I will try it but the caveat is that I am applying this customization to BricsCAD. I greatly appreciate your concern and generosity!

 

Clint 

Posted
On 12/7/2025 at 6:43 PM, devitg said:

@Clint Please give it a try 

 

 

(defun c:lay-nam-to-capital (/  (ACAD-OBJ ADOC LAY-COLL))
  (VL-LOAD-COM)
  (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT))  
  (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) 
  (SETQ LAY-COLL (VLA-GET-LAYERS ADOC))
  (vlax-for lay	lay-coll
    (vla-put-name lay (strcase (vla-get-name lay)))
  ) ;_ end of vlax-for
) ;_ end of defun

 

@devitg

I thank you for your suggested subject line (of course!) Much more so, your submission to eliminate all undesired layer name text cases.

 

Thanks,

Clint

Posted
On 12/6/2025 at 8:46 AM, Steven P said:

 

 

Obviously we don't have your batch LISP - I guess your company paid for this and so you are not going to be popular sharing that for all online.

 

LISPs can be added to scripts - both as a command and as code. There are others out there such as ScriptPro and Lee Macs Script Writer which will do this. BigAl will often post snippets of scripts here to batch process files - last one he did was in the last week or so ago. You could even set this up as a stand alone script to do just the one task (see BigAls last example....)

 

The first step for all is to get a LISP working as you want and well on a single file and then to do it as a batch (first time running the batch with a new LISP, perhaps check carefully that it doesn't do anything unexpected on other files). Plenty of examples out there to change layer names from one to another - have a look to see if you see one you like to use, or if there isn't am sure we can put one together - and use what is above as a started if you want to have a go, I think all the code you need is in the examples, just need to think how to change them to your needs

 

 

 

Hi Steven P and all the fine colleagues here,

 

I have been distracted by producing content for a department-wide customization package based in BricsCAD.

 

Steven P,

 

Your comments are sound and will be pursued. My lack of focus on my programming learning shows - embarrassingly.

Let's see what i can do about gaining LISP knowledge and its practical application!

 

Thanks for everything.

 

Clint

  • Like 1

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