(vl-load-com)
(defun C:MBL ( / obj bname odist scale p_ent c_lay p_obj minExt maxExt i_obj ss ans)
(cond
((and (setq obj (vlax-ename->vla-object (car (entsel "\nSelect Block Entity: "))))
(eq (vla-get-objectname obj) "AcDbBlockReference")
(setq bname (if (vlax-property-available-p obj 'effectivename)
(vla-get-effectivename obj)
(vla-get-name obj)
)
)
(princ (strcat "\nBlock Name : " bname))
)
(setq odist (getdist "\nEnter Distance between Blocks :"))
(setq scale (getreal "\nEnter Scale for Blocks : "))
(while (setq p_ent (car (entsel "\nSelect polyline: ")))
(setq c_lay (getvar 'clayer))
(setq p_obj (vlax-ename->vla-object p_ent))
(vla-GetBoundingBox p_obj 'minExt 'maxExt)
(command "_measure" p_ent "_b" bname "_y" odist)
(if
(ssget "_C"
(vlax-safearray->list minExt)
(vlax-safearray->list maxExt)
(list (cons 0 "INSERT") (cons 8 c_lay) (cons 2 bname))
)
(progn
(vlax-for i_obj (setq ss (vla-get-activeselectionset
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(vla-put-xscalefactor i_obj scale)
(vla-put-yscalefactor i_obj scale)
(vla-put-zscalefactor i_obj scale)
)
(initget "Yes No")
(setq ans (getkword "\nRotate Blocks 180? [Yes No] : "))
(if (= ans "Yes")
(vlax-for i_obj ss
(vla-put-rotation i_obj (+ pi (vla-get-rotation i_obj)))
)
)
(vla-delete ss)
)
)
)
)
)
(princ)
)