@jtm2020hyowrote:
I need insert blocks in segment polyline midpoint.
OK. The lisp below will work for Lines, all Polylines (straight and curved), Splines and Arcs. It allows multiple lines to be selected and will process all selected lines. At present it will not selected any entity on a locked layer. If you want that changing let me know.
Lines, Arcs and Splines work as before, one block mid point of line.
Straight Polylines (LW £D) block mid point of each segment.
Curved polylines.
There is a problem here. Due to the nature of Spline fits you end up with a lot of extra segments. The lisp will put a block on the mid point of every segment.
Fitted Curves have double the number of segments to its straight counterpart. Again a block is inserted at the mid point of each segment.
It is possible to reduce the number of inserted blocks for curved polylines by half. If you want me to do this let me know.
Finally do you want the blocks inserted onto the same layer as the line|polyline|spline|arc?
(vl-load-com)
(defun c:Mins ( / *error* c_doc ms blk_name ss l_obj m_dist m_pt s_ang n_obj params param)
(defun *error* ( msg )
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
(princ)
);_end_*error*_defun
(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
ms (vla-get-modelspace c_doc)
);end_setq
(while (not blk_name)
(setq blk_name (getstring t "\nSpecify Block Name : "))
(cond ( (not blk_name)
(alert "You must specify a Block Name")
)
( (not (tblsearch "BLOCK" blk_name))
(alert (strcat "Block Name : " blk_name " NOT found in drawing!!"))
(exit)
)
);end_cond
);end_while
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(vla-startundomark c_doc)
(prompt "\nSelect Lines|Polylines|Splines|Arcs : ")
(setq ss (ssget ":L" '((0 . "LINE,LWPOLYLINE,POLYLINE,SPLINE,ARC"))))
(vlax-for l_obj (vla-get-activeselectionset c_doc)
(cond ( (wcmatch (vla-get-objectname l_obj) "*Polyline");was 2DPolyline
(setq params (vlax-curve-getparamatpoint l_obj (vlax-curve-getendpoint l_obj))
param 0.5
);end_setq
(while (< param params)
(setq m_pt (vlax-curve-getpointatparam l_obj param)
s_ang (angle '(0 0 0) (vlax-curve-getfirstderiv l_obj (vlax-curve-getparamatpoint l_obj m_pt)))
n_obj (vla-InsertBlock ms (vlax-3d-point m_pt) blk_name 1 1 1 s_ang)
param (1+ param)
);end_setq
);end_while
);end_sub_cond
(t
(setq m_dist (/ (vlax-curve-getdistatpoint l_obj (vlax-curve-getendpoint l_obj)) 2);
m_pt (vlax-curve-getpointatdist l_obj m_dist)
s_ang (angle '(0 0 0) (vlax-curve-getfirstderiv l_obj (vlax-curve-getparamatpoint l_obj m_pt)))
n_obj (vla-InsertBlock ms (vlax-3d-point m_pt) blk_name 1 1 1 s_ang)
);end_setq
);end_sub_cond
);end_cond
);end_vlax-for
(setq ss nil)
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(princ)
);end_defun
(princ)
I am not one of the robots you're looking for