@Anonymous ,
On message #5 i also attached blktag.dwg did you use it? guess not!
the lisp was design to use this block (only because you did not provide something else before) so you can not expect it will work with POLE_ID_BLOCK?!
when prompt for select object(s) you should select only the text than the program will let you insert your block and assign the attributes.
i'm sending a fix to support POLE_ID_BLOCK as default block name but if you like another name, just set USERS1 (sysvar) with another default block name.
enjoy
moshe
(defun c:test (/ get-kword-value ; local function
bname savAttDia savAttReq ss ename1 elist data_text value)
(defun get-kword-value (text kword / p0 p1 p2)
(if (and
(setq p0 (vl-string-search (strcase (strcat "$" kword)) (strcase text)))
(setq p1 (vl-string-position (ascii "=") (substr text (1+ p0))))
)
(if (not (setq p2 (vl-string-position (ascii "$") (substr text (+ 1 p1 p0)))))
(substr text (+ 2 p0 p1))
(substr text (+ 2 p0 p1) (- (+ p0 p1 p2) (+ p0 p1) 1))
); if
); if
); get-kword-value
(setvar "cmdecho" 0)
(command "._undo" "_begin")
; initialize
(if (eq (getvar "users1") "")
(setq bname (setvar "users1" "pole_id_block"))
(setq bname (getvar "users1"))
)
(if (setq ss (ssget '((0 . "text"))))
(progn
(setq savAttDia (getvar "attdia"))
(setvar "attdia" 0)
(setq savAttReq (getvar "attreq"))
(setvar "attreq" 0)
(foreach ename0 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq elist (entget ename0))
(setq data_text (cdr (assoc '1 elist)))
(command-s "._insert" bname)
(setq ename1 (entlast))
(foreach kword '("PoleNumber" "Owner" "Attachment1")
(if (/= (setq value (get-kword-value data_text kword)) "")
(setpropertyvalue ename1 kword value)
)
); foreach
); foreach
(setvar "attreq" savAttReq)
(setvar "attdia" savAttDia)
); progn
); if
(command "._undo" "_end")
(setvar "cmdecho" 0)
(princ)
); c:test