• 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

TEXTSPLIT LISP: Break a Line of Text Into Two

August 6, 2026

TEXTSPLIT splits a text object in two and puts the second half where you point. For a note that has run too long for its box, a title that needs to wrap, or a line of imported text that came in as one string when it should have been three.

What TextSplit does

Three ways to say where to cut:

After     after a word you name - the usual way
Position  after a character count
Half      at the nearest space to the middle

The second piece keeps the height, style, rotation, width factor, layer and colour of the original, so the two halves match.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type TEXTSPLIT.
  3. Pick the text.
  4. Choose After, Position or Half.
  5. Pick where the second half goes.

How it works

DXF group codes are integers. The original read the text out of the object with (assoc (quote 1.0) entdata), and likewise 40.0 and 50.0 for the height and rotation — group codes written as reals.

assoc compares with equal, under which 1 and 1.0 are not the same thing. Every one of those lookups returned nil, so the text came back as nil and the first (strlen nil) stopped it. The routine could not run at all.

The search for the split word is bounded. Looking for a word that is not in the string, an unbounded loop walks off the end, where substr returns an empty string forever — which never matches — so it hangs until Escape.

Every property is copied to the second half, not just the string, so the two pieces are indistinguishable from text that was always two lines.

Notes and limits

  • TEXT objects. MTEXT wraps on its own.
  • The second half keeps every property of the first.
  • A word that is not there is reported, not hunted for forever.
  • One undo group covers the split.

Download and details

NameTextSplit — break a line of text in two
DownloadTextSplit.lsp — 7.6 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandTEXTSPLIT
Requiresnothing beyond a CAD platform with AutoLISP.
Source size7.6 KB, 193 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

  • RESPACE LISP — evening up the lines once you have split them
  • WORDSWAP LISP — find and replace across text objects
  • TEXTCLONE LISP — copying text with its formatting intact
  • 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