Last updated July 28, 2026
ADDLENGTH totals the length of everything you select and prints the result at the command line. Select a run of lines and arcs, and it tells you how many metres of them there are. The obvious use, and the one the listing gives, is a bill of materials take-off: pipe runs, cable trays, handrail, kerb lengths, fencing — anything where the drawing already holds the geometry and you need the number.
It is a short routine and it does its job, but there is one limitation that will bite anyone using a current release of AutoCAD, so it is worth covering before anything else.
It ignores modern polylines
The routine tests the type of each object you select and handles three of them: lines, arcs and polylines. The catch is which kind of polyline. AutoCAD has drawn lightweight polylines by default since Release 14, and the internal name for those is LWPOLYLINE. The routine checks for POLYLINE, the older heavyweight type, and nothing else.
A lightweight polyline therefore fails all three tests, falls through to the catch-all branch, and is quietly removed from the selection without being measured. Nothing is reported. You get a total that silently excludes every polyline you drew with the PLINE command — and if your selection was mostly polylines, you can get a total of zero on a screen full of geometry.
There are two ways around it. Convert the polylines to the old format before measuring, or add LWPOLYLINE to the routine’s list of accepted types. It is a two-line change and the same handler already in the file will measure them correctly, because it works by calling AutoCAD’s own AREA command rather than reading the vertices. Circles, ellipses and splines are not handled either, and are dropped the same silent way.
What it does in practice
Everything you select goes into a pile, and the routine works through it one object at a time, removing each from the pile as it is dealt with. Lines are measured from end to end. Arcs get proper arc-length treatment: the routine takes the centre, radius, start angle and end angle from the object, works out the included angle — correctly handling arcs that cross the zero-degree mark — and takes that fraction of the full circumference. Heavyweight polylines are handed to AutoCAD’s AREA command and their perimeter is read back.
The running total is printed at the end to two decimal places in your current drawing units. There is no output to file and nothing is written into the drawing, so it is safe to run on live work.
One thing to be aware of if you fold this into anything larger: the routine declares no local variables, so the total and its working values are left behind as globals after it finishes. Run it twice without thinking and you are still fine — the total is reset at the start of each run — but the variables persist in the drawing session.
Command reference
The file defines one command, ADDLENGTH, plus three internal helpers for the three object types it understands.
How to load it
This download is a bare .lsp file rather than a zip, so there is nothing to extract — save it somewhere on AutoCAD’s support file search path and load it with APPLOAD, or add it to the Startup Suite. Our AutoLISP guide covers the options.
Step-by-step usage
- Type ADDLENGTH.
- At “Select all objects to count:” select the geometry. Any selection method works.
- Press Enter to close the selection. The routine reports “Total length is:” followed by the figure.
Sanity-check the first result. Measure one known line with the DIST command and confirm the total moves by that amount when you include it. That will tell you straight away whether the objects you care about are the ones being counted.
Compatibility notes
The listing records it as working on AutoCAD 2006. It is plain AutoLISP with no dialog boxes and no Express Tools calls, so nothing in it requires the full product; LT users on LT 2024 or later, the release that brought AutoLISP to LT, should be able to run it. See what runs on AutoCAD LT. It only reads the drawing, so there is no risk to your geometry — the risk is in trusting a total that may have skipped things.
Download
| Name: | Addlength |
| Description: | Add individual lenghts of lines together for a grand total. Useful for Bill Of Materials take offs. |
| Type: | AutoCAD AutoLISP Routine |
| Author: | Anon |
| File Size: | 4 Kb |
| Cost: | Free |
| Worked on: | AutoCAD 2006 |
| Download File: | Addlength.lsp |
Related routines
- ZONE — totals length or area for every polyline on a layer, and handles both polyline types correctly.
- DISTBEAR — label individual lines with their length and bearing.
- Best of LISP collection — more general drafting utilities in one download.