(setq ctb 0)[color="green"];;;counter for blocks[/color]
(setq ctl 0)[color="green"];;;counter for lines[/color]
[color="red"](while (< ctb (sslength ssb))[/color] [color="green"];;;begin while blocks [/color]
[color="red"](setq ed (ssname ssb ctb)
cd (cdr(assoc 10 (entget ed)))
d1 '(0 0))[/color]
[color="red"] (while (< ctl (sslength ssl))[/color] [color="#2e8b57"][color="green"];;; iterate ssl for the nearest line for ssname (ed);;;[/color][/color]
[color="red"](setq el (ssname ssl ctl)
vla-el (vlax-ename->vla-object el)
d (vlax-curve-getClosestPointToProjection vla-el cd '(0 0 0)))
(if (< (distance cd d) (distance cd d1)) (setq p vla-el d1 d))[/color][color="green"];;;store the nearest line and loop[/color]
[color="green"];;;store nearest distance for compare;;;[/color]
(setq ctl (+ ctl 1))
) [color="green"];;;end while looking for nearest line for block ed;;;[/color]
(setq ctb (+ ctb 1))
(_line cd (vlax-curve-getClosestPointToProjection p cd '(0 0 0))) [color="green"];;; draw a line from the block;;;;[/color]
[color="green"] ;;; to the nearest line;;;
);;;end while blocks[/color]
(princ)
)[color="green"];;;end defun[/color]
(vl-load-com)
(defun _line ( a b ) (entmakex (list (cons 0 "LINE") (cons 10 a) (cons 11 b))))