Try this. It will only work on blocks that are on the end of lines/polylines
You are asked to select a typical block, this is to get the block layer and name to define the selection set. The lisp will the select all similar blocks provided the block layer is not locked. It then selects all lines and compares the insertion point of the block with the start and end points of each line in the drawing. If a match or near match is found using a fuzz of 0.001, the block is rotated to align with the line and moved to the end of the line. If it is on the end of a line it is rotated 180 degrees to the alignment.
Type RB2L to run the lisp once loaded
(defun rh:ss2lst( ss opt / cnt lst)
(cond ( (and ss (= (type ss) 'PICKSET))
(repeat (setq cnt (sslength ss)) (setq lst (cons (ssname ss (setq cnt (1- cnt))) lst)))
(if opt (setq lst (mapcar 'vlax-ename->vla-object lst)))
)
( (or (not ss) (/= (type ss) 'PICKSET)) (setq lst -1))
);end_cond
);end_defun
(defun rh:align_ang (itm pt) (angle '(0. 0. 0.) (vlax-curve-getfirstderiv itm (vlax-curve-getparamatpoint itm pt))))
(defun rh:assoc_val (dxf_code ent) (if (= (type dxf_code) 'INT) (cdr (assoc dxf_code (entget ent)))))
(vl-load-com)
(defun C:RB2L (/ *error* c_doc ent lyr bname fuzz b_lst i_pt e_pt ang)
(defun *error* ( msg )
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred.")))
(princ)
);end_*error*_defun
(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
ent (car (entsel "\nSelect Typical Block to be Rotated : "))
lyr (rh:assoc_val 8 ent)
bname (rh:assoc_val 2 ent)
fuzz 0.001
b_lst (rh:ss2lst (ssget "_A" (list '(0 . "INSERT") (cons 2 bname) (cons 8 lyr))) T)
);end_setq
(cond (b_lst
(setq l_lst (rh:ss2lst (ssget "_X" '((0 . "*LINE"))) T))
(foreach blk b_lst
(setq i_pt (vlax-get blk 'insertionpoint))
(foreach l_obj l_lst
(cond ( (equal i_pt (setq e_pt (vlax-curve-getstartpoint l_obj)) fuzz)
(setq ang (rh:align_ang l_obj e_pt))
(mapcar '(lambda (x y) (vlax-put blk x y)) (list 'insertionpoint 'rotation) (list e_pt ang))
)
( (equal i_pt (setq e_pt (vlax-curve-getendpoint l_obj)) fuzz)
(setq ang (+ (rh:align_ang l_obj e_pt) pi))
(mapcar '(lambda (x y) (vlax-put blk x y)) (list 'insertionpoint 'rotation) (list e_pt ang))
)
);end_cond
);end_foreach
);end_foreach
)
);end_cond
(princ)
);end_defun
I am not one of the robots you're looking for