What it does
Set Text Height with the SETTXTH AutoLISP command
Updates the height group of selected text objects while preserving their content, insertion point, layer, and style.
- AutoLISP command
- SETTXTH
- Difficulty
- Beginner
Applicable disciplines
CAD workflows that use this routine
Requirements and compatibility
What it needs
Software rows marked “Not tested” are not compatibility claims. Test the routine in a copy of your drawing and CAD version.
Downloadable source code
Review the set-text-height.lsp AutoLISP code
;; CADLisp Tools - Set Text Height
(defun ct-th:editable-p (data / flags row)
(and data
(setq row (tblsearch "LAYER" (cdr (assoc 8 data))))
(setq flags (cdr (assoc 70 row)))
(= 0 (logand flags 20))))
(defun c:SETTXTH (/ *error* changed data ent height i skipped ss undo-started)
(defun *error* (message)
(if undo-started (command-s "_.UNDO" "_End"))
(if (and message (not (wcmatch (strcase message) "*CANCEL*,*QUIT*,*EXIT*")))
(prompt (strcat "\nSETTXTH error: " message)))
(princ))
(initget 6)
(if (setq height (getreal "\nNew text height (>0): "))
(progn
(prompt "\nSelect TEXT or MTEXT: ")
(if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
(progn
(setq changed 0 skipped 0)
(if (= 0 (logand 8 (getvar "UNDOCTL")))
(progn (command "_.UNDO" "_Begin") (setq undo-started T)))
(repeat (setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i))) data (and ent (entget ent)))
(if (and (ct-th:editable-p data) (assoc 40 data)
(entmod (subst (cons 40 height) (assoc 40 data) data)))
(progn (entupd ent) (setq changed (1+ changed)))
(setq skipped (1+ skipped))))
(if undo-started (progn (command "_.UNDO" "_End") (setq undo-started nil)))
(prompt (strcat "\nUpdated " (itoa changed) " object(s); skipped " (itoa skipped) ".")))
(prompt "\nNo text selected."))))
(princ))
Setup
How to install the set-text-height.lsp file
- 1Download and review the source code.
- 2Load the .lsp file with APPLOAD in a copy of a drawing.
- 3Keep the routine session-only until it has been tested for your CAD version and standards.
Command workflow
How to run the SETTXTH command
- 1Run SETTXTH.
- 2Enter a height greater than zero.
- 3Select TEXT or MTEXT and press Enter.
Worked example
Example: Set selected notes to 2.5 drawing units high.
- Run SETTXTH.
- Enter 2.5.
- Select the notes.
Selected text has height 2.5 unless constrained by its style.
Read before use
Notes and limitations
- Fixed-height text styles may override entity height behavior.
- Does not change annotative scales.
- Not manually CAD-tested.
Version history