Just taking a shot and what I assume you're looking for:
edit: forgot about the rounding part oops. Gonna see what I can do there if anything.
edit2: Threw in Lee Mac's roundm function, but I haven't tested it. Still no fractions
edit3: I think I broke it... You can change DISTR to DIST to just get the length with no rounding for now if you'd like, it'll work in that way.
edit4: Fix'd-er up, and it displays fractions! (I'm also pretty sure the code could be a bit better. I change the data-type of DIST and DISTR probably needlessly)
(defun LM:roundm (n m) ;gotta love Lee Mac (http://www.lee-mac.com/round.html)
(* m (fix ((if (minusp n) - +) (/ n (float m)) 0.5)))
)
(defun c:linelength (/ s e) ;function taken from helpful post by Tharwat @ https://www.cadtutor.net/forum/topic/55856-lisp-to-get-length-of-single-line/
(princ "\n Pick on one line to get its length :")
(if (setq s (ssget "_+.:S:E" '((0 . "LINE"))))
(progn
(setq DIST (rtos (distance (cdr (assoc 10 (setq e (entget (ssname s 0))))) (cdr (assoc 11 e))) 2))
(setq DISTR (LM:roundm (distof DIST) 0.125))
(setq DISTR (rtos DISTR 5))
(command "TEXT" PAUSE PAUSE 90 DISTR)
(princ)
)
)
)
You select the line, then select where you want the text of the length to be placed, then choose a size for the text. It then plops it where you set with the 90* rotation applied.
Hope that helps