Hi Vince !
This code flip the attribute text in the tag named "open-size" in all block named "Open-tag" automatically
from "AAAAxBBB" to "BBBxAAAA". Run the code again to change the text back.
If you want to select your block manually, look in the code, oterwhise all legal blocks are treated.
Code:
(defun c:FlipOpen-Size ( / Item SelSet BlName AttName EntDxf AttTxt xpos NewTxt )
(setq Item 0 ) ;; Remove the "_X" at next line if you want to select your block manually
(if (setq SelSet (ssget "_X" (list (cons 0 "INSERT") (cons 2 "Open-tag" ))) ) ; <-- Your block name
(while (setq BlName (ssname SelSet Item ) )
(setq AttName (entnext BlName ) )
(while AttName
(if (equal (assoc 0 (entget AttName )) '(0 . "SEQEND"))
(setq AttName nil )
(if (= (cdr (assoc 2 (entget AttName ))) (strcase "open-size" nil ) ) ; <-- Your Attribute name
(progn
(setq EntDxf (entget AttName ) )
(setq AttTxt (cdr (assoc 1 (entget AttName ))) )
(setq xpos (vl-string-position (ascii "x") AttTxt ) )
(setq NewTxt (strcat (substr AttTxt (+ xpos 2 ) ) "x" (substr AttTxt 1 xpos )) )
(setq EntDxf (subst (cons 1 NewTxt ) (assoc 1 (entget AttName )) EntDxf ) )
(entmod EntDxf )
(entupd BlName )
(setq AttName (entnext AttName ))
)
(setq AttName (entnext AttName ))
)
)
)
(setq Item (1+ Item ) )
)
(princ "no matching block in drawing" )
)
(princ)
)
: ) Happy Computing !
kennet