Try this. You are asked to select the block you wish to insert. From this the lisp knows the block name and layer. You are then asked to select a Line/LWPolyline etc and the blocks are inserted. Since the lisp doesn't know how the blocks are orientated you are asked if you want to rotate the blocks 90 degrees (default option No) selecting Yes will rotate the blocks for the line. You are then looped back and asked to select another line. To exit the loop select a blank area of screen.
The blocks are never inserted at 2100 centres unless the line length is exactly divisible by 2100.
(defun rh:yn (msg default / tmp)
(initget 6 "Yes No")
(setq tmp (cond ( (getkword (strcat msg " [Yes/No] < " default " > : "))) (default)))
);end_defun
(vl-load-com)
(defun rh:entsel (msg e_lst / obj ent)
(while (not obj)
(setq ent (car (entsel msg)))
(if (vl-position (cdr (assoc 0 (entget ent))) e_lst) (setq obj (vlax-ename->vla-object ent)) (alert "Selected entity is NOT a Block"))
);end_while
obj
);end_defun
(defun C:MBCL ( / *error* sv_lst sv_vals c_doc c_spc b_obj b_name b_sc sel ent e_pt e_len b_dist t_dist i_pt r_ang n_obj b_lst)
(defun *error* ( msg )
(mapcar 'setvar sv_lst sv_vals)
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred.")))
(princ)
);_end_*error*_defun
(setq sv_lst (list 'dynmode 'dynprompt 'cmdecho 'osmode 'clayer)
sv_vals (mapcar 'getvar sv_lst)
c_doc (vla-get-activedocument (vlax-get-acad-object))
c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
);end_setq
(mapcar 'setvar sv_lst '(3 1 0 0))
(setq b_obj (rh:entsel "\nSelect Block Entity : " (list "INSERT"))
b_name (if (vlax-property-available-p b_obj 'effectivename) (vlax-get b_obj 'effectivename) (vlax-get b_obj 'name))
lyr (vlax-get b_obj 'layer)
b_sc 1.0
);end_setq
(setvar 'clayer lyr)
(while (setq sel (entsel "\nSelect Line/Polyline/Spline Entity : "))
(setq ent (car sel) b_lst nil)
(cond ( (vl-position (cdr (assoc 0 (entget ent))) (list "SPLINE" "POLYLINE" "LWPOLYLINE" "LINE"))
(setq e_pt (vlax-curve-getendpoint ent) e_len (vlax-curve-getdistatpoint ent e_pt) t_dist 0.0)
(if (equal (rem (/ e_len 2100) 1.0) 0.0 1.0e-4) (setq b_dist 2100) (setq b_dist (/ e_len (1+ (fix (/ e_len 2100))))))
(while (or (< t_dist e_len) (equal t_dist e_len 1.0e-4))
(setq i_pt (vlax-curve-getpointatdist ent t_dist))
(if (not i_pt) (setq i_pt e_pt))
(setq r_ang (angle '(0 0 0) (vlax-curve-getfirstderiv ent (vlax-curve-getparamatpoint ent i_pt)))
n_obj (vlax-invoke c_spc 'insertblock i_pt b_name b_sc b_sc b_sc r_ang)
b_lst (cons n_obj b_lst)
t_dist (+ t_dist b_dist)
);end_setq
);end_while
(if (= (rh:yn "\nRotate Blocks 90?" "No") "Yes") (foreach blk b_lst (vla-put-rotation blk (+ (* pi 0.5) (vla-get-rotation blk)))))
)
);end_cond
(setq b_lst nil
t_dist b_dist
);end_setq
);end_while
(mapcar 'setvar sv_lst sv_vals)
(princ)
);end_defun