I was hoping for a simple modification on the below AutoLisp code. With emphasis on the 5.0 offset (commented), I would want a that triangle to snap to the line, offset by a distance so it usually would not touch the line.
The text would be adjacent to the block, and the two lines should not be stacked, I was thinking that they could be consecutive lines, as if an MTEXT.
(defun c:m2l ( / l_ss b_ss b_cnt b_ent i_pt min_dist m_pt l_cnt l_ent c_pt md m_ang)
(prompt "\nSelect Lines : ")
(setq l_ss (ssget "_X" '((0 . "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE") (8 . "SPPC-E-EL"))))
(prompt "\nSelect Blocks : ")
(setq b_ss (ssget '((0 . "INSERT") (2 . "552-2,551-1,552-0-CO"))))
(repeat (setq b_cnt (sslength b_ss))
(setq b_ent (ssname b_ss (setq b_cnt (1- b_cnt)))
i_pt (cdr (assoc 10 (entget b_ent)))
min_dist 1000000
m_pt nil
)
(repeat (setq l_cnt (sslength l_ss))
(setq l_ent (ssname l_ss (setq l_cnt (1- l_cnt)))
c_pt (vlax-curve-getclosestpointto l_ent i_pt)
)
(cond ( (< (setq md (distance i_pt c_pt)) min_dist)
(setq min_dist md
m_pt c_pt
)
)
)
)
(setq m_ang (angle i_pt m_pt)
m_pt (polar i_pt m_ang (- min_dist 5.0));;5.0 = radius of circle in block
)
(vla-move (vlax-ename->vla-object b_ent) (vlax-3d-point i_pt) (vlax-3d-point m_pt))
)
(princ)
)