This was posted here not too long ago:
;;Re: How can I get the total length of several lines?
;; LENGTH.LSP Copyright 2003, Tony Tanzillo
;;
;; Provided for private use only, reproduction or
;; redistribution expressly prohibited.
;;
;; Adds LENGTH command to AutoCAD which when used, will report
;; the total length of all selected 2D curves (including lines,
;; polylines, arcs, splines, and elliptical curves).
;;
;; Does not add length of CIRCLES.
(defun C:LENGTH ( / ss len i)
(vl-load-com)
(setq ss (ssget '((0 . "LINE,ARC,SPLINE,ELLIPSE,POLYLINE,LWPOLYLINE")))
len 0.0
)
(repeat (setq i (sslength ss))
(setq len (+ len (getlength (ssname ss (setq i (1- i))))))
)
(write-line (strcat "\nTotal length = " (rtos len)))
(princ)
)
;---;
(defun getLength (ename / acurve len)
(setq ACurve (vlax-ename->vla-object ename))
(setq len 0.0)
(vl-catch-all-apply
'(lambda ()
(setq len
(vlax-curve-getDistAtParam
ACurve
(vlax-curve-getEndParam ACurve)
)
)
)
)
len
)
Bill