Last updated July 28, 2026
PDIST labels a polyline with running distances. Pick one, and it writes the cumulative length above every vertex — zero at the start, then the distance travelled at each corner, all the way to the total at the end. It is chainage annotation for anything measured along its length: a road centreline, a pipe run, a fence, a boundary traverse.
It is by Art Whitton, and unusually for a routine of this size it is written as a teaching example: the header carries a full variable table, and the code is split into four named parts — a setup function, the working part, a clean exit and a replacement error handler. If you want to see how a small AutoLISP program should be structured, this is a better read than most.
Read the first line of the file before you download
The author’s own warning is unambiguous, and it is the first thing in the file: Release 13 and earlier only. The description repeats it: it does not work with lightweight polylines.
That is a hard limit, not a caution. The routine reads a polyline’s vertices as separate objects following the polyline itself, which is how the older heavyweight polylines are built. Lightweight polylines, which AutoCAD has created by default since Release 14, keep their vertices inside the single object — there is nothing for the routine to step through. It refuses them outright rather than misbehaving: the selection loop only accepts an entity whose type is POLYLINE, so clicking a modern polyline simply re-prompts.
That refusal is the good news. Several routines of this era read whatever object happens to sit next in the drawing and produce nonsense; this one checks first. If you want to use it on a current release, set PLINETYPE to 0 before drawing the polyline, or convert an existing one to the old format.
What it does in practice
Text is placed bottom-centre justified, sitting half a text height above each vertex, so the labels clear the line itself. The height comes from your current text style; if that style has no fixed height, the routine asks for one and will not accept zero or a negative number.
It starts by writing zero at the first vertex, then adds each segment length as it walks along, writing the running total at every subsequent vertex. Segment lengths are straight point-to-point distances, so an arc segment in the polyline is measured as the chord rather than along the curve — worth knowing if your centreline has curves in it.
The housekeeping is thorough. Command echo, blip mode and object snap are all saved before it starts and restored afterwards; snap is turned off while it works so the text lands exactly on the computed points; and the whole run is wrapped in an undo group so a single U removes every label. The replacement error handler restores all of it even if you cancel partway through, and it exits quietly on a deliberate cancel rather than reporting a fault.
Command reference
The file defines a single command, PDIST. It announces itself when it loads with “Loaded…type <pdist> to run.”
How to load it
Unzip Pdistr13.zip and load pdistr13.lsp with APPLOAD. There are no support files. Our AutoLISP guide covers loading, and the file itself is worth opening in a text editor whether or not you run it.
Step-by-step usage
- Make sure the polyline is the old heavyweight type, and set the layer and text style you want the labels on.
- Type PDIST.
- At “Pick a 2D polyline entity as your source:” click the polyline. Anything else re-prompts.
- If your text style has no height set, it asks for one. Type a value or pick a distance.
- The running distances appear above each vertex. If they are the wrong size, undo, change the text style height and run it again.
Compatibility notes
Release 13 and earlier, by the author’s own statement, and the polyline structure it depends on stopped being AutoCAD’s default at Release 14. Treat it as a routine for old drawings, for drawings where you control PLINETYPE, or as source to learn from and adapt — the vertex walk is the only part that would need rewriting to support lightweight polylines.
It is plain AutoLISP with no dialog boxes and no Express Tools calls, so nothing in it requires the full product, and LT users on LT 2024 or later face the same polyline limitation as everyone else. See what runs on AutoCAD LT. It only adds text and does not touch the polyline, so nothing of yours is at risk.
Download
| Name: | Polyline Distance |
| Description: | This program will enable the user to pick on a 2D polyline and have the cumulative distances displayed above each vertex of the polyline. |
| Type: | AutoCAD AutoLISP Routine |
| Author: | Art Whitton |
| File Size: | 2 Kb |
| Cost: | Free |
| Worked on: | AutoCAD |
| Download File: | Pdistr13.zip |
Related routines
- ZONE — totals length or area by layer, and handles both polyline types.
- ADDLENGTH — a running total from a selection rather than per-vertex labels.
- Join 2 Polylines — join the runs up before you chainage them.