• 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

RUNLENGTH LISP: Measure Along a Chain Between Two Points

August 3, 2026

RUNLENGTH measures the distance along a chain of connected objects between two points. Select a run of connected lines, arcs and polylines — a pipe route, a kerb line, a cable run — then pick two points anywhere on it. The result is the true travelled distance following the geometry, not the straight-line distance between the picks.

What RunLength does

The two points may sit on different objects with any number of objects between them, or on the same object.

The selection may contain several separate chains. If the two picks land on different chains, you are told so rather than being given a meaningless number — which is the failure that matters, because a plausible wrong distance on a setting-out drawing is worse than no answer.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type RUNLENGTH.
  3. Select the run of connected objects.
  4. Pick the two points to measure between.
  5. Read the distance at the command line.

How it works

First the selection is sorted into chain order — the objects are put into the sequence you would walk them, each one flipped if necessary so its start point meets the previous object’s end point. Drawing order and direction are irrelevant after that.

The chain is then searched for the object carrying the first pick, and the remainder searched for the one carrying the second.

The total is the part-length of the first object from the pick to its far end, plus the full length of every object in between, plus the part-length of the last object up to the second pick.

The disconnection test falls out of that for free. If the search for the second point finds nothing in the remainder of the chain, the two picks are not connected — which is exactly how the “not on the same chain” case is detected, with no separate check needed.

The result honours the drawing’s LUNITS and LUPREC settings.

Notes and limits

  • Closed objects are excluded. A circle or closed polyline has no free ends, so it can neither join a chain nor be traversed through.
  • Endpoints must genuinely coincide for the chain to sort. Segments that only look joined break it.
  • Different chains are reported, not averaged. You get a message rather than a number.
  • It only reads the drawing, so there is no undo group.

Download and details

NameRunLength — measure the distance along a chain of connected objects
DownloadRunLength.lsp — 12.3 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandRUNLENGTH
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com).
Source size12.3 KB, 290 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

  • FOLLOWON LISP — select the whole connected chain in one pick first
  • TAPE LISP — total the length of a whole selection instead of part of a run
  • SEGREPORT LISP — every segment of one polyline in full detail
  • 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