Are you sure that you have the block name in the same directory of the current opened drawing ?
(defun c:Test (/ o x e l path)
(princ "\n Select Polyline ")
(if (and (setq o (ssget "_+.:S" '((0 . "POLYLINE"))))
(setq x (ssname o 0))
(while (and (setq x (entnext x))
(member '(0 . "VERTEX") (setq e (entget x)))
)
(setq l (cons (cdr (assoc 10 e)) l))
)
(setq path (findfile (strcat (getvar 'DWGPREFIX) "pindiat.dwg")))
)
(progn
(command
"_.-insert"
path
nil
)
(if (tblsearch "BLOCK" "pindiat")
(entmake
(list
'(0 . "INSERT")
(cons 2 "pindiat")
(cons
10
(list
0.
(- 14
(cadar (vl-sort l
'(lambda (j k) (< (cadr j) (cadr k)))
)
)
)
0.
)
)
)
)
)
)
)
(if (not path)
(alert "Block name is not found in Directory !!")
)
(princ)
)