This isn't pretty, but it does return the invert at the closest picked point.
Code:
(defun c:getinvert (/ _getparam _myspace end0
end1 height inv0 inv1 pick
pipe point space tempLine
)
(defun _getparam (pipe param)
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property pipe 'pointatparam param)
)
)
)
(defun _myspace (/ adoc space)
(vl-load-com)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(setq space (if (= 1 (vla-get-activespace adoc))
(vla-get-modelspace adoc)
(if (= (vla-get-mspace adoc) :vlax-true)
(vla-get-modelspace adoc)
(vla-get-paperspace adoc)
)
)
)
)
(if (and (setq pipe (entsel "\nSelect pipe: "))
(setq pick (getpoint "\nSpecify point: "))
(setq pipe (car pipe))
(setq pipe (vlax-ename->vla-object pipe))
)
(progn
(setq end0 (_getparam pipe 0.0)
end1 (_getparam pipe 1.0)
height (vlax-get-property pipe 'InnerHeight)
inv0 (mapcar '- end0 (list 0.0 0.0 (* 0.5 height)))
inv1 (mapcar '- end1 (list 0.0 0.0 (* 0.5 height)))
tempLine (vla-addline
(_myspace)
(vlax-3d-point inv0)
(vlax-3d-point inv1)
)
)
(vla-put-visible tempLine :vlax-false)
(setq point (vlax-curve-getclosestpointto tempLine pick))
(vla-delete tempLine)
point
)
)
)