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) )
We have a found some thing very critical situation
I have all text same text but text names are different an example (T10 & T5) these both are same but i want select only T5 how can i select whole drawing to catch only T5 please let me know if you achieve this hadik :p
From your question, I think that you are describing 2 scenarios:
1) Selecting Text that contains “T5” spelled out in the text
2) Selecting all text that is on a text style named “T5”
Either way, both can easily be done within AutoCAD.
To select text that has “T5” in it, use the FIND command
To select objects that are using the text style named “T5” use the command SELECTSIMILAR
or use filter to select a textstyle
Pingback: How To Change All Text Font In Autocad | Cambodia News
Pingback: How To Change Text Style In Autocad 2010 | CamHR
I tried your code in AutoCAD 2019.
The routine appears to run well, but at the end an error is displayed: “; error: Automation Error. Key not found”
I tried changing the last line
from: (vla-regen objDocument 0)
to: (vla-regen objDocument acAllViewports)
However, the error persists.
I inserted another drawing that required text updating. Running the code again failed. I suspect due to the previous error.
The drawing must be saved, closed, and then reopened to let the code run once again.
Thanks for your time. I hope you can recommend a solution.
When I used it in AutoCAD 2018 it changed nearly all of the text. Love it!
Does this work on Tables??