I am looking for a way to rename specific characters in a block name. For example, if the 3rd and 4th characters of a selected block name are CS, FC or ND I want those characters changed to DN.
I wrote the following routine a year or so ago to update our tile block. Now I want it to check the block name and change it but I have no clue how I can do this. I tried (command "-rename") but it does not accept wildcards.
So I am looking for way to check the block name in "tbname" and rename based on the criteria in my first paragraph above. Any help would be appreciated.Code:(defun updatetitleblock ( / vss tbname sync ntbname BlkEnt EntData lgname) (setq vss (car (entsel "\nSelect Titleblock to Update: "))) (setq tbname (cdr (assoc 2 (entget vss)))) (if (findfile (setq ntbname (strcat "Z:/Autodesk 2009/JRSym/TitleBlocks/"tbname".dwg"))) (progn (command "-insert" (strcat tbname"="ntbname) "y") (command) (initget "Yes No") (setq sync (getkword "\nUpdate attribute locations [Yes/No] <Y>: ")) (princ (strcat "\n"tbname" redefined.")) ) (princ (strcat "\nCould not find "ntbname)) ) (setq BlkEnt (tblobjname "block" tbname)) ; get titleblock block definition ename (while (setq BlkEnt (entnext BlkEnt)) ; this will step through all the entities within the block (setq EntData (entget BlkEnt)) ; get the dxf list of the entity (if (and (= (cdr (assoc 0 EntData)) "INSERT") ; make sure it is a block (wcmatch (strcase (cdr (assoc 2 EntData))) "LOGO*") ; make sure the block name starts with LOGO ) (progn (setq lgname (cdr (assoc 2 EntData))) (command "-insert" (strcat lgname"=Z:/Autodesk 2009/JRSym/Logos/JRLogos/"lgname) "y") (command) (princ (strcat " "lgname" redefined.")) ) ) ) (if (= sync nil) (setq sync "Y") ) (if (or (= (substr sync 1 1) "Y") (= (substr sync 1 1) "y") (= sync "")) (progn (command "attsync" "n" tbname) ) ) (princ) ) (defun c:updatetitleblock () (updatetitleblock)) (defun c:udtb () (updatetitleblock))