Text height for mtext in AutoLISP

Text height for mtext in AutoLISP

Anonymous
Not applicable
1,061 Views
3 Replies
Message 1 of 4

Text height for mtext in AutoLISP

Anonymous
Not applicable

Hello, how can I define text size (height) in the following code?

(defun c:pdm (/ ins str)
  (and (or (> (getvar 'DWGTITLED) 0)
           (alert "Save the drawing then try again!")
       )
       (setq ins (getpoint "\nChoose where you want to insert the file name : "))
       (setq str (entmakex (list '(0 . "MTEXT")
                                 '(100 . "AcDbEntity")
                                 '(100 . "AcDbMText")
                                 (cons 10 (trans ins 1 0))
                                 '(1 . "")
				
                           )
                 )
       )
       (vla-put-textstring (vlax-ename->vla-object str)

			"{\\fArial|b1|i0|c0|p34;\\C2;%<\\AcVar Filename \\f \"%tc4%fn6\">%}"

)
  )
  (princ)
)
0 Likes
Accepted solutions (1)
1,062 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Hello, how can I define text size (height) in the following code?


That's the DXF 40 entry.  If it's something that varies, and you have it asked for or calculated, and in a YourHeight variable:

....
  (cons 10 (trans ins 1 0))
  (cons 40 YourHeight)
  '(1 . "")
....

or, if not in a variable but as an always-known constant value:

....
  (cons 10 (trans ins 1 0))
  '(40 . YourHeight)
  '(1 . "")
....

 

YourHeight would be, or in the first case could be a variable containing, a real [decimal] number in drawing units.

Kent Cooper, AIA
0 Likes
Message 3 of 4

ronjonp
Mentor
Mentor

Thread HERE too...

0 Likes
Message 4 of 4

john.uhden
Mentor
Mentor

I've pretty much discovered, especially with annotative text, that it's better to use a text style with a fixed height of zero.  With fixed heights other than zero you end up stuck with the fixed height.  Yes, I think you can override mtext with formatting codes, but i don't like using them, personally.

John F. Uhden

0 Likes