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

Retrieving current Paper Text Height

7 REPLIES 7
Reply
Message 1 of 8
John_Olthafer
377 Views, 7 Replies

Retrieving current Paper Text Height

I'm fairly new to LISP... so need a little help.  This seems simple but I can't find the system variable that I need.

 

I'm looking for code to retrieve the "Paper Text Height" from the current (active) "Text Style".

 

I have searched and found something about Group Code DXF 41 but I am not familiar with how to use these in LISP.

 

Any help would be greatly appreciated!

7 REPLIES 7
Message 2 of 8
Kent1Cooper
in reply to: John_Olthafer


@John_Olthafer wrote:

.... 

I'm looking for code to retrieve the "Paper Text Height" from the current (active) "Text Style".

 

I have searched and found something about Group Code DXF 41 but I am not familiar with how to use these in LISP.

....


The 41 code is the width factor of a Text Style, so I don't think that's going to be the answer.

 

I don't have a new-enough version to have a differentiated "paper text height" in Text Styles, but if that's a characteristic of the Style definition, it won't be in a System Variable.  But the name of the current (active) Style is stored in the TEXTSTYLE System Variable.  Try:

 

(tblsearch "style" (getvar 'textstyle))

 

to get the Style's definition, and see if it's in there.  Or better yet, because it has descriptive names for Properties:

 

(vlax-dump-object (vlax-ename->vla-object (tblobjname "style" (getvar 'textstyle))))

 

If it's a Style with a defined height of 0, you can get the height at which it was last used, that is, the current height for that Style:

 

(vla-get-LastHeight (vlax-ename->vla-object (tblobjname "style" (getvar 'textstyle))))

 

[which also works for fixed-height Styles, but I think would always be the same as the defined height].

Kent Cooper, AIA
Message 3 of 8
John_Olthafer
in reply to: Kent1Cooper

Thanks Kent for replying so quickly.   I think you are on to something.

When i run your tblsearch code i get the following...

 

Command: (tblsearch "style" (getvar 'textstyle))
((0 . "STYLE") (2 . "TEXTSTYLENAME") (70 . 0) (40 . 0.09375) (41 . 1.0) (50 . 0.0) (71 . 0) (42 . 0.2) (3 . "stylu.ttf") (4 . ""))

 

The fourth return (40) is the number that i was looking to retrieve (0.09375).  Now I just need to figure out how to extract that number... but that shouldn't be too hard.

 

Thanks again.

Message 4 of 8
Kent1Cooper
in reply to: John_Olthafer


@John_Olthafer wrote:

...When i run your tblsearch code i get the following...

 

Command: (tblsearch "style" (getvar 'textstyle))
((0 . "STYLE") (2 . "TEXTSTYLENAME") (70 . 0) (40 . 0.09375) (41 . 1.0) (50 . 0.0) (71 . 0) (42 . 0.2) (3 . "stylu.ttf") (4 . ""))

 

The fourth return (40) is the number that i was looking to retrieve (0.09375).  Now I just need to figure out how to extract that number....


That's just the defined height of the Style.  There are no additional entries in the definition than what I get back in ol' 2004, so there's nothing to indicate any differentiation between Paper and Model Text Height, which means if that's a version-dependent differentiation that is made, it must be handled otherwise than through the Style definition, such as perhaps by extended data attached to the Style as an object from (tblobjname), or something.

 

Getting that number out of there would be done this way:

 

(cdr (assoc 40 (tblsearch "style" (getvar 'textstyle))))

Kent Cooper, AIA
Message 5 of 8
John_Olthafer
in reply to: Kent1Cooper

Kent... why would sometimes that code work for me... and other times I get this???

 

Command: (cdr (assoc 40 (tblsearch "style" (getvar "texstyle"))))
; error: bad argument type: stringp nil

 

Thanks again.

Message 6 of 8
Kent1Cooper
in reply to: John_Olthafer


@John_Olthafer wrote:

 

Kent... why would sometimes that code work for me... and other times I get this???

 

Command: (cdr (assoc 40 (tblsearch "style" (getvar "texstyle"))))
; error: bad argument type: stringp nil

....


[Because you got to it before I fixed it....  I had originally left the second t out of "textstyle", but noticed shortly after posting it -- that's why my reply has been Edited.]

Kent Cooper, AIA
Message 7 of 8
John_Olthafer
in reply to: Kent1Cooper

LOL  ok sorry.  I guess when I typed it in it worked and when I cut and pasted it didn't.

 

That is exactly what I needed.  Thank you very much!  Smiley Happy

Message 8 of 8

You have probably found this, the system variable for text height is "textsize" (getvar "textsize") - but that just gives you the last used text size regardless of model or paper space.

 

You could run a test on it to see if it is greater than expected for paper space text height and go from there?

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

Post to forums  

Autodesk Design & Make Report

”Boost