Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lisp instruction needed to change the system variable "TEXTSIZE"

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
delliston
826 Views, 5 Replies

lisp instruction needed to change the system variable "TEXTSIZE"

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?

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: delliston


@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

 

EESignature

Tags (1)
Message 3 of 6
hmsilva
in reply to: delliston

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

EESignature

Message 4 of 6
Kent1Cooper
in reply to: delliston


@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.

Kent Cooper, AIA
Message 5 of 6
DINGUBOY
in reply to: delliston

(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))

)

)

Message 6 of 6
delliston
in reply to: Kent1Cooper

Thanks for the execellent instruction, you make it sound simple and clear!

Thanks
Dennis

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost