AutoLISP: Capital Text – Choose Some Not All

This routine is great because not every text object in a drawing needs to be capitalized and this routine lets you simply select the text objects that you want to be capitalized.

It’s that simple…

BTW – it works with DTEXT as well as MTEXT

Here’s how:

  • ALLCAPS <enter> to start
  • Select text objects that are to be capitalized
  • <enter> when finished selecting objects

 

;|

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

;ALLCAPS.LSP - (c) 1997-2001 Tee Square Graphics

;

;Converts selected text strings to all upper case characters.

; Written 08/21/97 for F&K Engineers.

; Updated 04/01/98 for AutoCAD R14.

; Modified 02/15/99 - minor improvements.

; Removed extra leading ";" from posted version 12/4/01.

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

;|;

(defun C:ALLCAPS (/ cmd ss n txt strg)

(command "_.undo" "_be")

(setq cmd (getvar "cmdecho"))

(prompt "\nSelect Text String(s) to modify: ")

(setq ss (ssget '((0 . "TEXT,MTEXT")))

n (sslength ss)) ; Count items.

(while (> n 0) ; While more to do,

(setq n (1- n) ; decrement count,

txt (entget (ssname ss n)) ; get entity,

strg (strcase (cdr (assoc 1 txt))) ; force to caps,

txt (subst (cons 1 strg)(assoc 1 txt) txt)) ; update entity,

(entmod txt)) ; change in dwg.

(setvar "cmdecho" cmd)

(command "_.undo" "_e")

(princ) ; Done!

)

;(alert (strcat

; "** ALLCAPS.LSP - (c) 1997-2001 Tee Square Graphics **\n\n"

; "Type ALLCAPS at the AutoCAD Command: line to start."))

;(princ)

 

 

 

Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Modifying, Text, TIPS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s