Clint Posted Wednesday at 07:11 PM Posted Wednesday 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 Wednesday at 10:22 PM Posted Wednesday at 10:22 PM (edited) You could try the search function... maybe this thread from lasty week might help? Edited Wednesday at 10:23 PM by Steven P 1 1 Quote
BIGAL Posted Wednesday at 11:42 PM Posted Wednesday at 11:42 PM (edited) removed Edited Wednesday at 11:43 PM by BIGAL Quote
Saxlle Posted yesterday at 11:01 AM Posted yesterday at 11:01 AM 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. 2 Quote
Clint Posted yesterday at 11:13 AM Author Posted yesterday at 11:13 AM 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 yesterday at 12:10 PM Posted yesterday at 12:10 PM (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 yesterday at 12:10 PM by Saxlle 1 1 Quote
mhupp Posted 22 hours ago Posted 22 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 20 hours ago by mhupp Quote
BIGAL Posted 17 hours ago Posted 17 hours 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 17 hours ago by BIGAL 1 Quote
mhupp Posted 17 hours ago Posted 17 hours 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 17 hours ago by mhupp Quote
BIGAL Posted 17 hours ago Posted 17 hours ago Yes should have dbl clicked still hard to see what is in dcl. Quote
Saxlle Posted 9 hours ago Posted 9 hours ago 8 hours ago, BIGAL said: just a comment a bit hard to see what is going on in video maybe use a screen area rather than full screen. I found this tool online (screenrec), but I'm not satisfied well. The reason is that I'm the using gifcap, so didn't work properly yesterday when tried to make video, so I find this as alternative. 8 hours ago, BIGAL said: 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. I've forgotten to mention this Multi toggles as alternative, so I agree with that it can be useful. Quote
Clint Posted 37 minutes ago Author Posted 37 minutes ago This is very superior feedback from both of you! Thanks a million! About this layer name conversion task: Expect all things to change including CAD standard layer name text cases! LAYER NAME TEXT CONVERSION BATCH PROCESSING - calling LISPS in SCRIPT FILES A BricsCAD-based, custom batch file program (Batcher.lsp) as developed for my company very recently. Currently it processes .SCR file types. QUESTION 1: Can .LSP programs be included from within script code lines? If so, ... BATH PROCESSING - SCRIPT FILE PURSUIT A: Convert both existing Title Case & lower case to UPPER CASE BATH PROCESSING - SCRIPT FILE PURSUIT B: Batch convert via the following LISP program. Prerequisite: Researching how to create the following LISP program Create a AutoLISP/Visual LISP program called LAYSUB.lsp This program reads from a old layer name list and a current layer list.* When old names are found from the old layer list, the program replaces the old layer string with current layer string. Proposed LISP Step 1: (*) Create a program resource text file for each layer list, old and current layer names as a program resource file. Proposed LISP Step 2: If old layers name case-sensitive string exist, substitute them with the new layer name case sensitive (UPPER) that is based on the two text file lists. SUMMARY Do the above pursuits sound reasonably practical for batch processing? Best regards, Clint Hill 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.