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
- Load the routine with
APPLOAD, or put it on your support file search path. - Type
RUNLENGTH. - Select the run of connected objects.
- Pick the two points to measure between.
- 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
| Name | RunLength — measure the distance along a chain of connected objects |
| Download | RunLength.lsp — 12.3 KB, plain AutoLISP source. Downloads directly; no zip to unpack. |
| Type | AutoCAD AutoLISP routine |
| Command | RUNLENGTH |
| Requires | the ActiveX layer (loaded automatically by the routine with vl-load-com). |
| Source size | 12.3 KB, 290 lines |
| Error handling | Yes — a *error* handler restores every system variable it changed, on cancel as well as on error. |
| Undo | Not needed — this routine only reads the drawing and changes nothing. |
| Compatibility | AutoCAD (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. |
| Author | YZ, August 2026 |
| Licence | Free 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