Jump to content

Recommended Posts

Posted

Hi,

 

I need help with the following issue

 

I have got a drawing that contains lots of text. The problem is that i need to turn them into UpperCase text and there are heaps of them. It'd be time consuming if i do it one by one. wonder if there're any easier way of doing this?

 

I'm using autocad 2005

 

Thank you in advance

Posted

If you have Express Tools installed, use the TCASE command to change case of selected text.

Guest Alan Cullen
Posted

If you have Express Tools you can do it easily.....

Express -> Text -> Change Text Case.

 

Otherwise use the following lisp routine (I have no idea who the original author was...I've had it for ages). Just pick everything....it only works on text....

 

(DeFun C:UPCASE (/ SS ENAME EDATA INDEX
   TEMP TEXT COUNT)
(prompt "\nSelect Text: ")
(if (SetQ SS (SSGet))
 (ProgN
  (SetQ INDEX -1 COUNT 0)
  (While (SetQ ENAME (SSName SS
   (SetQ INDEX (1+ INDEX))))
   (SetQ EDATA (EntGet ENAME))
   (If (Eq (Cdr (Assoc 0 EDATA))
     "TEXT")
    (Progn
     (SetQ TEMP (Assoc 1 EDATA)
           TEXT (StrCase (Cdr TEMP))
          EDATA (SubSt (Cons 1 TEXT)
                    TEMP EDATA)
          COUNT (1+ COUNT)
     )
     (EntMod EDATA)
  )))
  (PrinC (StrCat "\n" (IToA COUNT)
        " text entities changed."))
))
(PrinC)
)

Posted

Thank you Allan and CarlB for your replies.

 

I have AutoCAD 2005 full version but i couldn't find it. I think i need to install it from the Autocad CD. Sadly, i misplaced the CD and don't know where it is :(

 

Allan, I tried the code you gave me and it works beautifully. However, it only works with TEXT only. How do i make it to work with MTEXT? because some of the text are made up using MTEXT rather than TEXT.

 

Thank you in advance

Guest Alan Cullen
Posted

Without getting too involved in tweaking the code.....for the time being just make a copy of the code to another name for MTEXT.....and edit the following line from....

 

"TEXT") to.... "MTEXT")

 

Alternatively just change the line "TEXT") to "MTEXT,TEXT")

 

i DON'T KNOW IF IT WILL WORK ON mtext,,,,BUT WORTH A GO....:)

Posted

Try this tweaking of Alan's code, modified to just select text and mtext, changes either;

 

(DeFun C:UPCASE (/ SS ENAME EDATA INDEX
   TEMP TEXT COUNT)
(prompt "\nSelect Text: ")
(if (SetQ SS (SSGet '((0 . "TEXT,MTEXT"))))
  (ProgN
     (SetQ INDEX -1 COUNT 0)
     (While (SetQ ENAME (SSName SS
        (SetQ INDEX (1+ INDEX))))
        (SetQ EDATA (EntGet ENAME))
        (SetQ TEMP (Assoc 1 EDATA)
              TEXT (StrCase (Cdr TEMP))
              EDATA (SubSt (Cons 1 TEXT)
                      TEMP EDATA)
               COUNT (1+ COUNT)
         )
         (EntMod EDATA)
     )
  )
  (PrinC (StrCat "\n" (IToA COUNT)
        " text entities changed."))
)
(PrinC)
)

Guest Alan Cullen
Posted

Thanks Carl......much neater tweaking of the code...:)

Posted

The code above is good, however can process MText not more longly 255 symbols, because such quantity of symbols contains in one DXFgroup (1 . "..."). I shall show the example on VisualLisp:

 

(defun c:upc(/ allTxt okCount errCount curStr)
 (vl-load-com)
 (princ "\n <<< Select Text and MText >>> ")
 (if
   (setq allTxt
   (ssget '((0 . "TEXT,MTEXT"))))
   (progn
     (setq allTxt
     (mapcar 'vlax-ename->vla-object
                   (vl-remove-if 'listp
                     (mapcar 'cadr(ssnamex allTxt))))
    okCount 0
    errCount 0); end setq
     (vla-StartUndoMark
(setq actDoc
       (vla-get-ActiveDocument
	 (vlax-get-acad-object))))
     (foreach txt allTxt
(setq curStr
       (strcase
	 (vla-get-TextString txt)))
(if
  (vl-catch-all-error-p
    (vl-catch-all-apply
      'vla-put-Textstring
      (list txt curStr)))
  (setq errCount(1+ errCount))
  (setq okCount(1+ okCount))
  ); end if
); end foreach
     (vla-EndUndoMark actDoc)
     (princ
(strcat "\n"(itoa okCount)
	" texts now changed to uppercase. Wait regeneration..."))
   (if(/= 0 errCount)
     (princ
(strcat "\n"(itoa errCount)
	" were on locked layer! "))
     ); end if
     ); end progn
   (princ ">>> Empty selection! <<< ")
   ); end if
 (princ)
 ); end of c:upc

  • 4 years later...
Posted

This lisp routine is good - however - it inserts XQL; in front of parts of text which is already upper case. Example - I have a drawing where each line of text begins with an upper case letter . " Maintain full insulation cover..." becomes XQL;MAINTAIN INSULATION COVER ....

 

Any fix for this please ?

Posted

I've tried 2 - ASMI's and CarlB's . Both insert the XQL; bit

Posted

Must be on your end, works fine here. Can you post a file with some of the text?

  • 5 months later...
Posted (edited)
Must be on your end, works fine here. Can you post a file with some of the text?

 

Here's some sample text that inserts XQL when changed to UpperCase using CarlB's program.

ToUpperCaseTest.dwg

Edited by Arepo
Posted

\pxql; is a justification control for Mtext. Just click the paragraph alignment button or preferred method to make Mtext all one case is in Mtext Editor, Select All, then Right-Click and Change Case or click one of the buttons.

 

[ATTACH=CONFIG]36023[/ATTACH]

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