Changing Text Case - Global

I collect survey information in a data recorder.
I have some old jobs where the Codes (Description of detail points surveyed) come in as UPPER case .

I want to (must) change all Code Text from UPPER case to lower.
Preferably the first letter would be Upper as in sentence text, but can handle all lower case.

Is there a routine that I can globally do that please?

regards

Comments

  • Hi Richard.

    here is one for converting between Upper and Lower case.
    [code]; **********************************************************************
    ;                             CAP.LSP
    ;
    ; Changes case of selected TEXT
    ;
    ; 01/02/95
    ; Jason Bourhill
    ; http://www.cadconcepts.co.nz

    ; **********************************************************************



    (defun C:CAP ( / chgcap sset ans caps)

    ;--------------------- Changes CASE of text -----------------------------
    (defun chgcap (sset caps / num env text ntxt)
      (princ "\nWorking please wait.")
      (setq num 0 )
       (repeat (sslength sset)
        (setq env (entget (setq ent (ssname sset num))))
         (setq text (cdr (assoc 1 env)) ntxt (strcase (cdr (assoc 1 env)) caps))
        (if (/= ntxt text)
            (progn ; Substitute new string for old
                (setq env (subst
                        (cons 1 ntxt)
                        (assoc 1 env)
                       env)
                )
                (entmod env); Modify the TEXT entity
            )
        )
         (setq num (1+ num))
       )
    )

    ;--------------------- Main program --------------------------------------

     (princ "\n**CAP use to change CASE of TEXT**")
     (princ "\nPick TEXT or MTEXT objects: ")
     (setq sset (ssget '((-4 . ""))) )
     (if sset (progn  ; If any objects selected
            (initget "Cap Small")
            (setq ans (getkword "\nChange to Cap/Small : "))
            (if (or (= ans "Cap")(= ans ""))(setq caps ())(setq caps ans))
            (chgcap sset caps)
            )
           (princ "\nNothing Selected")
     )
    ;(defun C:CAP () (flnf (load "cap" "CAP")))
    (prin1)
    )

    ;(C:CAP)[/code]

    Express tools includes a command with more options

    Regards,

    Jason Bourhill

    CAD Concepts
  • Thanks Jason
    Normally I get these to work, but this evades me.

    I get an error message when APPLOAD and add the CAP.lsp and type CAP

    Loading C:\Jobs_2011\00_Bricscad\CAP.LSP
    : (LOAD "C:/Jobs_2011/00_Bricscad/CAP.LSP")
    ; ----- Error around expression -----
    (LOAD "C:/Jobs_2011/00_Bricscad/CAP.LSP")
    ;
    "malformed list on input at [READ] : File "

    I created a new .lsp file (saved a previous lsp as CAP.lsp.
    It looks like below.  Have I missed or 'messed' (probably latter) something please.
    regards
    Richard

    (defun C:CAP ( / chgcap sset ans caps);--------------------- Changes CASE of text -----------------------------(defun chgcap (sset caps / num env text ntxt)  (princ "\nWorking please wait.")  (setq num 0 )   (repeat (sslength sset)    (setq env (entget (setq ent (ssname sset num))))     (setq text (cdr (assoc 1 env)) ntxt (strcase (cdr (assoc 1 env)) caps))    (if (/= ntxt text)        (progn ; Substitute new string for old            (setq env (subst                    (cons 1 ntxt)                    (assoc 1 env)                   env)            )            (entmod env); Modify the TEXT entity        )    )     (setq num (1+ num))   ));--------------------- Main program -------------------------------------- (princ "\n**CAP use to change CASE of TEXT**") (princ "\nPick TEXT or MTEXT objects: ") (setq sset (ssget '((-4 . ""))) ) (if sset (progn  ; If any objects selected        (initget "Cap Small")        (setq ans (getkword "\nChange to Cap/Small : "))        (if (or (= ans "Cap")(= ans ""))(setq caps ())(setq caps ans))        (chgcap sset caps)        )       (princ "\nNothing Selected") );(defun C:CAP () (flnf (load "cap" "CAP")))(prin1));(C:CAP)

  • Hi Richard,

    the fabulous forum formatting has stripped some of the characters out from my code. Have attached the file instead.

    Regards,

    Jason Bourhill

    CAD Concepts

    cap.lsp

  • thanks Jason
    fixed.
    works well
    Much appreciated.
    regards
    Richard
This discussion has been closed.