A few months ago I attempted to tackle some of this type of code, through no small assistance of the others in this forum namely hmsilva lee mac and a few others over at the autodesk forums. After much testing and deliberation this is the portion of code we've decided on and have used successfully since then:
(if (setq insertpt1 (getpoint "\nPick Insertion Point: "))
(progn
(if (and (setq ntsel (nentselp insertpt1))
(= (length ntsel) 2)
(setq name (car ntsel))
(wcmatch (cdr (assoc 0 (entget name)))"LINE,LWPOLYLINE")
);; and
Additionally, and this may or may not be useful for the OP but I want to show how the (vlax-curve-getpointatparam) function was used in addition to the break command. I am not sure if this has already been looked at , or would not work- just wanted to share in case it may be found to be useful.
(if (eq (vla-get-ObjectName obj) "AcDbPolyline")
(setq p3 insertpt1
p2 (angle insertpt1 (vlax-curve-getpointatparam obj (fix (vlax-curve-getparamatpoint obj insertpt1)))))
(setq p3 insertpt1
p2 (angle (vlax-curve-getStartpoint obj) (vlax-curve-getEndPoint obj)))
)
(command "break" name (polar p3 p2 a2) (polar p3 p2 a3))
The reasons that the portions of code are the way they are is because of the conditions in which we require the program to work properly. If one user wishes to insert their fittings onto blank space before connecting them together in-line, they can. At the same time if another user wishes to draw a routing line and place all of their fittings onto that line, then the prog will do so. It will then trim out any lines that remain under the fittings. Speaking of lines, most of the time we use lwpolylines but wanted to ensure this code would work for any typical condition that we may use: lwpolylines, lines, blank space.
Hope that helps a little if you were still looking for a method....as I did not see the functions being used here explained by Lee i'm wondering where they'd fit in with his get-closest-point-to diagram.....