• 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

TEXTSHELL LISP: A Box Around Text That Keeps Up With It

August 3, 2026

Draw a rectangle, circle, slot or rounded rectangle around a piece of text, and it stays around that text. Edit the wording and the shell resizes. Change the height, style or justification and it resizes. Move, rotate or copy the text and the shell follows.

What TextShell does

This is the difference between a shell and a box you drew yourself. A drawn box is right once. A shell is right permanently — which matters on revision clouds, room tags, detail markers and any label that gets edited twice a week for six months.

Four shapes: rectangle, a plain box offset evenly around the text; filleted, with rounded corners; slot, with fully rounded left and right ends; and circle, through the box corners, for balloon-style tags.

The offset factor is a multiple of the text height, not a fixed distance, so a shell around 2.5 mm text and one around 100 mm text look the same. Change the text height and the gap scales with it.

How to use it

  1. Load the routine from acaddoc.lsp if you want shells live in every drawing — see the note below.
  2. Type TEXTSHELL.
  3. Pick the text and choose the shape and offset factor.
  4. Edit the text freely. The shell keeps up.
  5. Type UNSHELL to break the link, leaving both objects as ordinary geometry.

How it works

Two pieces of machinery hold the pairing together.

Extended entity data. Both the text and its shell carry a small block of xdata under a private application name, each recording the handle of its partner plus the shape and offset factor. Handles are used rather than entity names because a handle is permanent — it survives saving, closing and reopening the drawing, where an entity name does not. That is what allows shells to keep working after the file has been round-tripped.

Object reactors. One watches every shelled text, another watches every shell. When either is modified, the callback reads the xdata, finds the partner by handle, and rebuilds the shell around the text’s current extents.

Why there is a command reactor dance. A modification reactor is forbidden from modifying the drawing while it is running — AutoCAD is mid-edit and the database is not safe to touch. So when a shell is dragged, the callback cannot immediately rebuild it. Instead it remembers which object needs attention and creates a temporary command reactor, which fires the moment the command finishes and the database is stable. That temporary reactor removes itself straight away, so they never accumulate.

The same trick handles copying. A copied shelled text inherits xdata pointing at the original shell, which would be wrong. The copy callback queues the new object and, once the command ends, builds it a shell of its own and repoints the xdata. Copying a shell on its own instead deletes the copy, since a shell with no text is meaningless.

Notes and limits

  • Reactors do not survive between drawings. The file re-establishes them from the xdata every time it is loaded, so load it from acaddoc.lsp if you want shells live everywhere.
  • Until it is loaded the shells are ordinary geometry. Nothing is lost; they just stop updating.
  • UNSHELL breaks the link and leaves both objects in place.
  • The offset is proportional, so one setting suits every text size.

Download and details

NameTextShell — a box around text that resizes when the text changes
DownloadTextShell.lsp — 48.7 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandsTEXTSHELL, UNSHELL
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com).
Source size48.7 KB, 1,191 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoThe whole operation is wrapped in a single undo group, so one U reverses all of it.
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

  • TEXTFRAME LISP — a static box, when a live one is more than you need
  • NUMSTAMP LISP — numbered labels with borders drawn to fit
  • STARTUPBUILD LISP — getting this loaded in every drawing automatically
  • 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