Below is some code for a routine i copied from the autodesk website. It works fine for a single block, however what i would like to do is more complicated(of course) I would like to select multiple blocks with different names, for example on block named "fpr" and another named "dr". after the selection is made i would like to replace the blocks with "fprd" and "drd" respectivley. Our block naming convention is "XXX" for our standard block and "xxxd" for our demo blocks. how can this code be modified so i can search our libraries for the blocks with the same names but with the "d" at the end of the block name. I assume a wildcard of some type. or maybe an if then argument.
Code:
(defun c:REPL (/ ENT1 BL1 NWNM OLD ODNM)
(prompt "Select blocks to replace: ")
(setq ENT1 (ssget))
;(setq NEWBL ("fprd"))
(command "insert" fprd nil)
(setq N (sslength ENT1))
(setq I 0)
(repeat N
(setq BL1 (entget (ssname ENT1 I)))
(setq NWNM (cons 2 "fprd"))
(setq OLD (assoc 2 BL1))
(setq ODNM (cdr OLD))
(entmod (subst NWNM OLD BL1))
(command "change" "p" "" "p" "la" "e-demo-powr" "" "")
(setq I (1+ I))
)
(prin1)
)