Try the following:
(defun c:lpr ( / e g p q )
(while
(not
(progn (setvar 'errno 0) (setq e (entsel))
(cond
( (= 7 (getvar 'errno))
(prompt "\nMissed, try again.")
)
( (null e))
( (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getclosestpointto e))
(prompt "\nInvalid object selected.")
)
( (setq e (car e))
(while (= 5 (car (setq g (grread t 13 0))))
(redraw)
(if (setq q (vlax-curve-getclosestpointto e (trans (cadr g) 1 0) t))
(grdraw (cadr g) (trans q 0 1) 1)
)
)
(if (= 3 (car g))
(progn
(entmake
(list
'(0 . "LINE")
(cons 10 (setq p (trans (cadr g) 1 0)))
(cons 11 (setq q (vlax-curve-getclosestpointto e (trans (cadr g) 1 0) t)))
)
)
(princ "\nLine endpoints: ") (princ p) (princ " | ") (princ q)
(princ "\nLength: ") (princ (distance p q))
)
t
)
)
)
)
)
)
(redraw) (princ)
)