Clint Posted yesterday at 07:11 PM Posted yesterday at 07:11 PM Application: BricsCAD V26 Goal: To modify layer names to display as UPPER CASE from Title Case (Example: From existing layer name as "Trim" to "TRIM") Issues: As coded, the existing layer names in Title Case are not being processed. The confirmation message wrongly states that UPPER CASE was applied to the layer names when it was not. Help Needed: Please review the attached program and suggest needed edits. Resources My programming skills continue to grow. I am assembling snippets from various sources. Best regards, Clint UPPERCASE-LAYER-NAMES.lsp Quote
Steven P Posted yesterday at 10:22 PM Posted yesterday at 10:22 PM (edited) You could try the search function... maybe this thread from lasty week might help? Edited yesterday at 10:23 PM by Steven P 1 1 Quote
Saxlle Posted 12 hours ago Posted 12 hours ago Maybe this kind of solution can be interesting (to use a multiple selection, use Shift+Left mouse click, to use a single selection, use CTRL+Left mouse click): ; ************************************************************************** ; Functions : CHRENLAYERS ; Description : Select Layers To Change It To UPPERCASE Or LOWERCASE ; Author : SAXLLE ; Date : December 04, 2025 ; ************************************************************************** (prompt "\nSelect Layers To Change It To UPPERCASE Or LOWERCASE!\nTo run a LISP type: CHRENLAYERS") (princ) (defun c:CHRENLAYERS ( / old_echo dcl_id fname fn laylist lay items rval acad name) (vl-load-com) (setq old_echo (getvar 'cmdecho)) (setvar 'cmdecho 0) (create_dialog) (collect_layers) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "Laylist" dcl_id)) (exit) ) (action_tile "cancel" "(cancel)") (start_list "ls") (mapcar 'add_list laylist) (end_list) (action_tile "ps1" "(read_items) (to_uppercase)") (action_tile "ps2" "(read_items) (to_lowercase)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (gc) (princ) ) (defun cancel () (done_dialog 0) (terpri) (prompt "Application running were finished...") (princ) ) (defun collect_layers () (setq laylist (list) lay (tblnext "LAYER" T) ) (while lay (if (not (equal (cdr (assoc 2 lay)) "0")) (setq laylist (cons (cdr (assoc 2 lay)) laylist) lay (tblnext "LAYER") ) (setq lay (tblnext "LAYER")) ) ) (setq laylist (vl-sort laylist '<)) ) (defun read_items () (setq acad (vla-get-activedocument (vlax-get-acad-object))) (setq items (get_tile "ls") rval (mapcar '(lambda (x) (nth x laylist)) (read (strcat "(" items ")"))) ) ) (defun to_uppercase () (foreach item rval (setq name (strcase item)) (vla-SendCommand acad (strcat "-RENAME LA " item (chr 13) name (chr 13))) (prompt (strcat "\nThe layer " item " were changed into the UPPERCASE!")) (setvar 'cmdecho old_echo) (princ) ) (done_dialog 1) ) (defun to_lowercase () (foreach item rval (setq name (strcase item T)) (vla-SendCommand acad (strcat "-RENAME LA " item (chr 13) name (chr 13))) (prompt (strcat "\nThe layer " item " were changed into the LOWERCASE!")) (setvar 'cmdecho old_echo) (princ) ) (done_dialog 1) ) (defun create_dialog () (setq fname (vl-filename-mktemp "Laylist.dcl") fn (open fname "w") ) (write-line "Laylist :dialog { label = \"Select layers to change it to UPPERCASE or LOWERCASE!\"; :list_box { key = \"ls\"; multiple_select = true; height = 10; width = 50; } :row { :button { label = \"Change to UPPERCASE >>\"; key = \"ps1\"; fixed_width = true; } :button { label = \"Change to LOWERCASE >>\"; key = \"ps2\"; fixed_width = true; } :button { label = \"Cancel\"; key = \"cancel\"; mnemonic = \"C\"; alignment = centered; fixed_width = true; is_cancel=true; } } }" fn) (close fn) ) Also, you can see the short video example of how it works. CHRENLAYERS.mp4 Best regards. 1 Quote
Clint Posted 12 hours ago Author Posted 12 hours ago Hi Gentlemen, Your code contributions for my learning is greatly appreciated! Hi Saxlle, I thank you for the nice video demonstration as well as the excellent program. It appears that my focus should be more on Visual LISP along with including the Dialog box code within the main program file. Best regards, Clint Hill Quote
Saxlle Posted 11 hours ago Posted 11 hours ago (edited) You're welcome @Clint . Yes, the DCL file are not necessary every time, but it can be helpful and user-friendly to accomplish desired result (like this one from an example video from above) if you have multiple choosing (for eg. buttons or check-boxes for Uppercase, Lowercase, Renaming, etc.). Best regards. Edited 11 hours ago by Saxlle 1 1 Quote
mhupp Posted 4 hours ago Posted 4 hours ago (edited) Could go with a third Middle option. (setq layname (ApplyCASE "LAYERNAME")) LaYeRnAmE .... (defun ApplyCaSe (s / i n ch out) (setq n (strlen s) i 1 out "") (while (<= i n) (setq ch (substr s i 1)) (setq out (strcat out (if (= (rem i 2) 0) (strcase ch T) (strcase ch) ) ) ) (setq i (1+ i)) ) out ) -Edit or a more realistic Option Only first letter UpperCase (setq layname (ApplyCASE "LAYERNAME")) Layername (defun ApplyCase (s / i n ch out) (setq n (strlen s) i 2 out (strcase (substr s 1 1) T)) (while (<= i n) (setq ch (substr s i 1)) (setq out (strcat out (strcase ch)))) (setq i (1+ i)) ) out ) Edited 3 hours ago by mhupp Quote
BIGAL Posted 34 minutes ago Posted 34 minutes ago (edited) @Saxlle just a comment a bit hard to see what is going on in video maybe use a screen area rather than full screen. Win 11, Shit+Window+R allows screen area record. Drag window area then start / stop. This may be useful rather than a list box can tick one or all choices, add an All option so one click. Examples in code. Multi toggles.lsp Edited 31 minutes ago by BIGAL Quote
mhupp Posted 23 minutes ago Posted 23 minutes ago (edited) 10 minutes ago, BIGAL said: a bit hard to see what is going on in video Hit the X button bottom Right. Edited 23 minutes ago by mhupp 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.