• 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

WORDSWAP LISP: Copy or Swap Text Between Any Two Objects

August 3, 2026

Click one piece of text, click another, and the wording moves across. WORDCOPY sends the first object’s text to the second; WORDSWAP exchanges the two.

What WordSwap does

What makes this worth having is the range of things it treats as “text”. Text and MText, block attributes, dimension text overrides, multileader text and multileader block attributes, and individual table cells — all interchangeable as sources and destinations.

So a room number can go straight from a table cell into a block attribute, or a dimension override can be copied into an MText note, without retyping anything and without any of the usual copy-paste hazards.

In WORDCOPY, typing M at the destination prompt switches to a window selection, so one source can be pushed into any number of destinations at once.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type WORDCOPY or WORDSWAP.
  3. Click the source, then the destination. Click directly on a table cell to address that cell.
  4. Type S at any prompt to change whether formatting is retained; the setting is remembered between sessions.
  5. Type M in WORDCOPY for multiple destinations.

How it works

The hard part is not moving the characters, it is moving them between objects with different ideas about formatting. MText, multileaders, dimensions and table cells all understand inline formatting codes. Plain Text and ordinary attributes do not — give them a formatted string and the raw codes appear on screen as gibberish.

So both objects are inspected and the string converted appropriately. Formatted to formatted carries the codes across intact, if Retain is on, or strips them if not. Formatted to plain strips them. Plain to formatted escapes any characters MText would misread as codes, so a backslash or a brace in the source survives as itself rather than becoming a formatting instruction.

Picking uses a grread loop rather than entsel, for two reasons. First, table cells: entsel returns the table as a whole, so the loop uses the table’s own HitTest method to work out which row and column the click landed in. Second, keywords: the loop reads typed characters as well as picks, which is what allows Settings, Multiple and Exit to be typed at the same prompt that is waiting for a click.

Typed keywords are matched the way AutoCAD’s own initget does — the capital letters of each option form its abbreviation, and any unambiguous prefix is accepted.

Notes and limits

  • Formatting conversion uses the Windows VBScript regular expression engine, present on every standard Windows installation. If it cannot be reached the command reports so and stops, rather than silently producing mangled text.
  • The Retain setting persists between sessions.
  • Each destination is converted on its own terms, so a multiple copy into mixed object types comes out correctly for each.
  • Table cells are addressable individually, which entsel alone cannot do.

Download and details

NameWordSwap — copy or swap text content between any two objects
DownloadWordSwap.lsp — 52.2 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandsWORDCOPY, WORDSWAP
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 size52.2 KB, 1,346 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

  • TEXTSWEEP LISP — batch find and replace across a whole folder
  • TEXTWELD LISP — merging text objects into one MText
  • STRINGTALLY LISP — count the text before you change it
  • 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