David,
Took a look at your routine & found some bugs.
Revised code:
(defun c:rnblk (/ bl ; Block List
tdef ; Table Definition
bn ; Block Name existing
bnt
fe
fd ;
nn ; New Name
)
;;"old_name" . "new_name"
(setq bl '(("Drillbit5" . "Drillbit")
("Drillbit3" . "Drillbit")
("Drillbit7" . "Drillbit")
)
)
;; itterate the Block Collection
(while (setq tdef (tblnext "BLOCK" (not tdef)))
(setq bn (cdr (assoc 2 tdef))
fe (cdr (assoc -2 tdef))
)
(princ (strcat "\n" bn))
(while fe
(and (setq fd (entget fe))
(= "INSERT" (cdr (assoc 0 fd)))
(setq bnt (cdr(assoc 2 fd)))
(setq nn (cdr (assoc bnt bl)))
(tblsearch "BLOCK" nn)
(entmod (subst (cons 2 nn) (assoc 2 fd) fd))
)
(setq fe (entnext fe))
)
)
(command "REGENALL")
(prin1)
)