devitg Posted December 8 Posted December 8 @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 1 Quote
Saxlle Posted Monday at 07:31 AM Posted Monday at 07:31 AM 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). Quote
Saxlle Posted Monday at 07:33 AM Posted Monday at 07:33 AM 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. Quote
devitg Posted Monday at 12:22 PM Posted Monday at 12:22 PM 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 Quote
Saxlle Posted Monday at 12:43 PM Posted Monday at 12:43 PM 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. Quote
ScottMC Posted 7 hours ago Posted 7 hours ago Excellent and encourages me all the more to learn more than lean so much.. Found a solution as when using a text with a space in front, it's automatically ignored.. Just slip this in after the: v (vla-get-TextString o) v (vl-string-left-trim " " v) ;; https://www.cadtutor.net/forum/topic/26510-remove-the-space-from-a-text/page/4/#findComment-324578 Quote
troggarf Posted 6 hours ago Posted 6 hours ago 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) ) Quote
Recommended Posts
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.