Is it possible to change the system variable "TEXTSIZE" with an autolisp routine? I have hundreds of drawings that have varying textsize settingings and I can't get it to let me change it, unless I go into "Style" and manually change the value to "0" before I run the routine, and there are simply too may drawings to do that everytime. So, is there a way to reset the textsize to 0 through Lisp?
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@Anonymous wrote:
Is it possible to change the system variable "TEXTSIZE" with an autolisp routine? I have hundreds of drawings that have varying textsize settingings and I can't get it to let me change it, unless I go into "Style" and manually change the value to "0" before I run the routine, and there are simply too may drawings to do that everytime. So, is there a way to reset the textsize to 0 through Lisp?
delliston,
I think it is not the "TEXTSIZE" system variable you need to modify , "TEXTSIZE" can't be zero, because it sets the default height for new text objects drawn with the current text style...
As you wrote "unless I go into "Style" and manually change the value to "0" before", you'll have to modify the STYLE text height.
Perhaps something like this:
(setq adoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (setq styls (vla-get-TextStyles adoc)) (vlax-for sty styls (vla-put-height sty 0.0) );; vlax-for
HTH
Henrique
delliston,
and for change only the current text style, maybe something like this:
(setq adoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (setq styls (vla-get-TextStyles adoc)) (setq cursty (getvar 'TEXTSTYLE)) (vlax-for sty styls (if (eq (vla-get-name sty) cursty) (vla-put-height sty 0.0) );; if );; vlax-for
HTH
Henrique
@Anonymous wrote:
Is it possible to change the system variable "TEXTSIZE" with an autolisp routine? I have hundreds of drawings that have varying textsize settingings and I can't get it to let me change it, unless I go into "Style" and manually change the value to "0" before I run the routine, and there are simply too may drawings to do that everytime. So, is there a way to reset the textsize to 0 through Lisp?
The answer to the initial question is yes -- (setvar 'textsize somevalue) -- but not in this case if you want it set to zero. TEXTSIZE contains the current height for Text/Mtext [the height of the last-drawn Text/Mtext object, whether specified by the User for a zero-height Style, or specified by the Style if it has a fixed height]. Since you can't draw Text/Mtext at zero height, zero is not a valid value for that System Variable. I assume from that and your description of using the Style command that you want to change not the System Variable, but rather the height assigned to a particular text Style in its definition, initially with a fixed height, to zero, so that the routine can give it the height you want when you use it. If so, that can be done in several ways.
You can add a (command) function in the beginning of the routine that redefines the Style in question, accepting default values for all prompts except the height:
(command "_.style" "YourStyleName" "" 0 "" "" "" "" "")
[The number of Enters at the end could be fewer if the font isn't one that allows vertical orientation.] You would need to do that separately for every Style you want so altered.
Or you can use (subst)/(entmod) on the entity data of the Style definition, obtained using (entget (tblojbname "style" "YourStyleName")), replacing the height entry with (40 . 0.0). You can do the same by way of the "Height" VLA Property, if you convert the Style definition to a VLA object.
Or, if whatever else you're doing allows you to make Text/Mtext objects using (entmake) rather than via commands, you can assign the height you want in the (entmake) list, and the defined height of the Style won't matter, so it won't need to be redefined.
(DEFUN C:FTV()
(SETQ
RV(GETDIST "\n ENTER FILTER TEXT HEIGHT:")
NR(GETDIST "\n ENTER NEW TEXT HEIGHT:")
FL(SSGET "X" (LIST(CONS 0 "TEXT")(CONS 40 RV)))
FE(SSLENGTH FL)
a 0
)
(REPEAT FE
(SETQ
E(ENTGET(SSNAME FL A))
NEW(CONS 40 NR)
OLD(ASSOC 40 E)
F(SUBST NEW OLD E)
)
(ENTMOD F)
(SETQ
A(1+ A))
)
)