Jump to content

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


Recommended Posts

Posted

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

Posted (edited)

You could try the search function... maybe this thread from lasty week might help?

 

 

Edited by Steven P
  • Like 1
  • Agree 1
Posted

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.

 

 

 

Best regards.

  • Like 1
Posted

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   

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