• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

TEXTSWEEP LISP: Find and Replace Across a Folder of Drawings

August 3, 2026

Build a list of find-and-replace pairs, point at a folder, and TEXTSWEEP applies every one of them to every drawing it finds — without opening a single drawing in the editor. AutoCAD’s own FIND works in one drawing, one search term at a time.

What TextSweep does

This is the project renamed at stage four, the consultant who changed their company name, the revision letter that has to move from A to B on two hundred sheets.

What is searched: single-line text, multiline text, block attributes, dimension text, multileader text, table cells, and the text inside block definitions — which changes every insertion at once. Each is switchable, and you can restrict the sweep to the whole drawing, model space only, or layouts only.

Search options: match case, whole words only, and ignore locked layers. Every character the regular expression engine treats as special is escaped before searching, so a search for A(1) finds exactly that rather than being read as a pattern.

How to use it

  1. Run it with Search Only first. See the warning below.
  2. Load the routine with APPLOAD, or put it on your support file search path.
  3. Type TEXTSWEEP.
  4. Build the list of find-and-replace pairs, or load a saved one by name.
  5. Choose the folder and the object types to search.
  6. Tick Search Only, run, and read the CSV report.
  7. Only then run it for real.

How it works

Preserving formatting is the hard part, and the reason a plain string substitution is not good enough.

MText stores its formatting inline: {\C1;RED} text is four visible characters of colour code wrapped round the word. Searching for text naively would match inside a font name; replacing across a formatting code would destroy it and leave raw codes on screen.

So the search runs against a masked copy of the string. Every formatting code, brace and escape is first identified by regular expression and replaced, character for character, with a placeholder that cannot appear in real text. The search then runs on that masked copy — so it can never match inside a code — but the positions it finds are used to edit the original string, which still has all its formatting intact.

Because the mask is exactly the same length as what it replaced, every position found in the masked copy is the correct position in the original. That length-for-length property is the whole trick.

Saved searches can be stored under a name and reloaded, which turns a company-wide renaming into a one-click job on every project it affects.

Notes and limits

  • Drawings are modified and SAVED without being opened, and there is no undo across files. Run it with Search Only first, read the report, and only then run it for real. Test on a copy of the folder. Every time.
  • Search Only changes nothing and reports what it would have replaced as a CSV listing every drawing, the old and new strings, the object type and its handle.
  • A drawing already open in this session is edited through its live document rather than through the file, so unsaved work is not lost — but it is left unsaved, for you to review and save yourself.
  • Searching block definitions changes every insertion at once. Powerful, and worth being deliberate about.

Download and details

NameTextSweep — batch find and replace across a whole folder of drawings
DownloadTextSweep.lsp — 88.8 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandTEXTSWEEP
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com); nothing extra — the dialog is written to a temporary file at run time and deleted again, so there is no .dcl to install.
Source size88.8 KB, 2,003 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoNot needed — this routine only reads the drawing and changes nothing.
CompatibilityAutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer.
AuthorYZ, August 2026
LicenceFree to use, supplied “as is” with no warranty.

References

  • WORDSWAP LISP — find and replace within a single drawing
  • TAGBATCH LISP — setting attribute values across drawings, with counters
  • ATTPULL LISP — extract attribute values across a folder first
  • More free AutoLISP routines on this site
  • Wisey’s Steel Shapes — free structural steel section drawing program

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in