That's a fun one to write.
This should work.
Command IBTV, for Insert Block To Vertex (feel free to change the function name)
;; 1. lisp prompt the user to select a ployline.
;; 2. lisp prompt the user to enter the vertex number.
;; 3. lisp inserting a block at the selected vertex.
(defun drawInsert (pt Nme)
(entmakex (list (cons 0 "INSERT")
(cons 2 Nme)
(cons 10 pt))))
;; LW Vertices - Lee Mac
;; Returns a list of lists in which each sublist describes
;; the position, starting width, ending width and bulge of the
;; vertex of a supplied LWPolyline
(defun LM:LWVertices ( e )
(if (setq e (member (assoc 10 e) e))
(cons
(list
(assoc 10 e)
(assoc 40 e)
(assoc 41 e)
(assoc 42 e)
)
(LM:LWVertices (cdr e))
)
)
)
;; Command IBTV, for Insert Block To Vertex (feel free to change the function name)
(defun c:ibtv ( / Nme pl vertices ind str_ pt)
(setq Nme "3014")
;; 1. lisp prompt the user to select a ployline.
(setq pl
(ssname
(ssget "_+.:S" (list (cons 0 "*POLYLINE")))
0)
)
;; 2. lisp prompt the user to enter the vertex number.
(setq vertices (LM:LWVertices (entget pl)))
;;(princ vertices)
(princ (length vertices))
(setq str_ (strcat
"\nEnter vertex number (1 to "
(itoa (length vertices) )
"): "
))
(if (and
(setq ind (getint str_))
(> ind 0)
(< ind (+ (length vertices) 1))
)
(progn
;; 3. lisp inserting a block at the selected vertex.
(setq pt (cdr (assoc 10 (nth (- ind 1) vertices))))
(drawInsert pt Nme)
)
)
(princ)
)