RecipesCount and measure
How do I get the total length of all lines and polylines on a layer in AutoCAD?
Type "total length of everything on layer PIPE-CW". cadssistant selects the lines, polylines, arcs and splines on that layer, sums each one's length with the curve functions in one AutoLISP pass, and replies with the total in drawing units plus the number of objects it measured. Nothing is modified. Ask for "a table by object" to see what was counted.
Checked 2026-10-30
total length of everything on layer PIPE-CW
Paste it into the palette, or pick it from the recipes inside the chat.
What cadssistant does
- Selects every LINE, LWPOLYLINE, POLYLINE, ARC, SPLINE and ELLIPSE on the layer with one ssget filter.
- Sums each object's length in a single AutoLISP pass; the snippet below does it with vlax-curve-getDistAtParam at the end parameter.
- Replies with the total and the count, in the drawing's units. Say "a table by object" or "grouped by layer" for the breakdown.
The same task in AutoLISP
(progn
(vl-load-com)
(setq ss (ssget "_X" '((0 . "LINE,LWPOLYLINE,POLYLINE,ARC,SPLINE,ELLIPSE") (8 . "PIPE-CW")))
i 0 total 0.0)
(if ss
(repeat (sslength ss)
(setq e (ssname ss i) i (1+ i))
(setq total (+ total (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))))))
total)Total length on PIPE-CW in drawing units. Change the layer name, or drop the (8 . …) pair for the whole drawing.
Good to know
- Geometry inside blocks is not included: the filter sees the block reference, not its contents. Say so if you need it counted.
More in count and measure
Command: CADSSISTANT
Works in AutoCAD 2024 and newer on Windows. Free trial, no card, no API key.
Get cadssistant