Today’s featured routine was posted by “Peter” at Augi.com found here: http://forums.augi.com/showthread.php?22959-Help-Changing-text-style-in-blocks
This routine helps changes the text style of text objects and even attributes inside of blocks to a user specified text style. This is helpful for when you receive drawings from another source and would like to change text styles to match your text styles.
For this routine to work, the desired text style must exist in the drawing.
The format of how to run this routine is different than other routines that you might be used to. You load the lisp routine as normal, but there isn’t a command that you enter at the commandline. What you do is pass feed the LISP routine the “function” that runs the routine and then the 2 variables in order for it to run.
The format that you feed the command line is:
(changestyle “oldtextstylename” “newtextstylename”)
changestyle = starts the function (starts the routine)
oldtextstylename = replace this text with the name of the text style that you would like to be replaced. Note – keep the name in “quotes”
newtextstylename = replace this text with the name of the text style that you would like to replace the previous style. Note - keep the name in “quotes”
;;; Changes objects that are set to one text style to another text style. Both styles need to be defined in the drawing. ;;; Posted by Peter ;;; http://forums.augi.com/showthread.php?22959-Help-Changing-text-style-in-blocks ;;; ;;; Use the foloowing format in the command line after loading the routine: ;;; (changestyle "oldtextstylename" "newtextstylename") ;;; (defun ChangeStyle (strStyle1 strStyle2 / entItem objBlock objDocument objItem ) (vl-load-com) (setq objDocument (vla-get-activedocument (vlax-get-acad-object))) (if (and (tblobjname "style" strStyle1) (tblobjname "style" strStyle2) ) (vlax-for objBlock (vla-get-blocks objDocument) (if (> (vla-get-count objBlock) 0) (progn (setq objItem (vla-item objBlock 0) entItem (vlax-vla-object->ename objItem) ) (while entItem (if (and (vlax-property-available-p (setq objItem (vlax-ename->vla-object entItem)) "StyleName") (= (strcase (vla-get-stylename objItem)) (strcase strStyle1)) ) (vla-put-stylename objItem strStyle2) ) (setq entItem (entnext entItem)) ) ) ) ) (princ "\nError check if styles exist: ") ) (vla-regen objDocument 0) )
