You can try this. It was written quick with not much error checking.
To run, type "foo" at the command prompt. Select the circles along the line / polyline you wish to connect to. Then select the line / polyline.
Before running the routine, make sure the correct layer is set as current.
Code:
(defun c:foo (/ selection pline sscount objpline inspoint intpoint entity)
(if (not (setq selection (ssget "_I" '((0 . "CIRCLE")))))
(progn
(prompt "\nSelect circles: ")
(setq selection (ssget '((0 . "CIRCLE"))))
)
)
(setq pline (entsel "\nSelect polyline: "))
(if (and
pline
(setq objpline (vlax-ename->vla-object (car pline)))
)
(repeat (setq sscount (sslength selection))
(setq
entity (entget (ssname selection (setq sscount (1- sscount))))
inspoint (cdr (assoc 10 entity))
intpoint (vlax-curve-getclosestpointto objpline inspoint)
)
(if intpoint
(command "_.line" "non" inspoint "non" intpoint "")
)
)
)
)