eplisp

AutoCAD Find and Replace LISP for Text and Attributes

Finds a piece of text in texts and block attributes and replaces it with another.

Commands: TXTREPLACE

Load the downloaded .lsp file with the APPLOAD command in AutoCAD or GstarCAD, then type the command name. How to load a LISP file

Download all tools in one file (138 KB)

TXTREPLACE is an AutoCAD find and replace LISP for TEXT, MTEXT and block attributes. It searches the selected objects for the text you type and replaces every occurrence with the new text. If you press Enter without selecting anything, it searches the whole drawing.

AutoCAD's built-in FIND command also does find and replace, with a dialog, more object types and options such as match case. TXTREPLACE is deliberately simpler: two prompts on the command line, then a short report of how many objects and replacements were changed. It is handy for updating repeated strings such as a date, a revision number or a project name in title blocks.

The whole operation is one undo group, so a single U restores everything if needed.

How to use it

  1. Load the file with APPLOAD and type TXTREPLACE.
  2. Select texts and blocks, or press Enter right away to search the whole drawing.
  3. Type the text to find; phrases with spaces are allowed.
  4. Type the replacement text and press Enter.
  5. Check the command line for the number of objects and replacements.

Notes and tips

  • The search is case-sensitive: searching for "Floor" will not match "FLOOR".
  • Only TEXT, MTEXT and attributes attached to block references are searched; dimension text, tables and fixed text inside block definitions are not changed.
  • In long MTEXT objects or text with inline formatting codes the search string may be split internally and not found.
  • Pressing Enter selects every text and attribute in model space and all layouts, so try it on a small selection first.

Frequently asked questions

How do I replace a word in every text of an AutoCAD drawing?

Run TXTREPLACE and press Enter at the selection prompt without picking anything. The search then covers all texts and block attributes in the drawing.

Why use this instead of the FIND command?

FIND offers a full dialog with more options. TXTREPLACE runs with two command-line prompts and updates block attributes directly, which is quicker for simple repeated edits.

Is the search case-sensitive?

Yes. The text must match exactly, including upper and lower case.