[AutoCAD LISP] Change and Match Multiple Text Sizes Instantly (TSZ.lsp)
Have you ever spent way too much time clicking through dozens of text objects
in AutoCAD just to change their height one by one? When working on complex
blueprints, keeping your annotations and labels at a consistent, readable
scale is crucial. However, doing this manually is a tedious, repetitive chore
that kills your productivity and hurts your wrists.
Without a dedicated tool, modifying text sizes across an entire drawing means
opening the properties panel for every single object or repeatedly using the
MATCHPROP command—which can still be slow and clumsy if you have different
text types scattered around.
That’s where the TSZ LISP comes to the rescue. It streamlines this entire
process into a single, seamless command.
Why You Should Use the 'TSZ' LISP
- Massive Time Saver: Select hundreds of Text and MText objects and update their heights simultaneously in a single click.
- Smart Memory Feature: It remembers your last used text height. You don’t need to re-type the value every time; just hit Enter to apply the same size.
- Easy Reset Option: Need to switch to a different size? Simply type 'Reset' or enter a new number to instantly update the global variable.
- Error-Free Precision: Ensures all selected text elements are precisely unified to the exact same scale, eliminating human error.
How It Works (Step-by-Step Guide)
- Load the LISP File: Drag and drop the TSZ.lsp file into your AutoCAD workspace, or load it via the APPLOAD command.
- Run the Command: Type TSZ in the command line and press Enter.
- Set the Text Height:
- If it's your first time running it, enter your desired text height.
- On subsequent runs, it will display your previous height as the default <value>. Press Enter to keep it, or type Reset to change the default height.
- Select Text Objects: Simply drag a selection box over the TEXT or MTEXT objects you want to modify. (Don't worry about accidentally selecting lines or blocks—the script automatically filters and picks only text elements).
-
Boom, Done!: Press Enter to finish the selection. The LISP will instantly
resize all chosen texts and display a success message in the command
line.
Wrapping Up
The TSZ LISP is an essential addition to any AutoCAD user's toolkit, designed to handle tedious text scaling tasks in seconds. By automating this repetitive process, you can maintain perfectly uniform drawings while freeing up time for actual design work.
Give this script a try, and let me know how much time it saved you in the comments below!
The LISP Code
(vl-load-com)
(defun c:TSZ ( / input ss i ent obj)
(if (not g_txtsize)
(setq g_txtsize (getreal "\nEnter new text height: "))
(progn
(initget "Reset")
(setq input (getreal (strcat "\nEnter text height or [Reset] <" (rtos g_txtsize 2) ">: ")))
(cond
((= input "Reset")
(setq g_txtsize (getreal "\nEnter new text height: "))
)
((numberp input)
(setq g_txtsize input)
)
)
)
)
(setq i 0)
(prompt "\nSelect text objects to change size: ")
(if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
(progn
(while (< i (sslength ss))
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent))
(vla-put-height obj g_txtsize)
(setq i (1+ i))
)
(prompt (strcat "\nSuccessfully changed to size " (rtos g_txtsize 2) "."))
)
(prompt "\nNo text selected.")
)
(princ)
)

Post a Comment