Code Red > AutoLISP (Vanilla / Visual)

Qestion about MTEXT

(1/2) > >>

FengK:
Hello,

Please see the attached image. Notice there is extra blank space in the MTEXT. It can be resized when you drag the grip. My question is how do you access this property via lisp? I'm going to dig into it myself, but thought I'd ask here as well. Maybe some of you already know the answer.

Thanks.

T.Willey:
Here is mine.


--- Code: ---(defun VALUE (num ent /)
(cdr (assoc num ent))
)
;-------------------------------------------------------------------------
(defun DTR (a) ;Degrees to radians conversion
(* pi (/ a 180.0))
)
;-------------------------------------------------------------------------
(defun GetMTextBB (Ent / EntData InsPt TxtJust TxtWd TxtHt TxtRot tmpPt)
; Get real Bounding Box for MText
; Tim Willey 03/2005
; Thanks to OLD-CADaver for the tips on the DXF codes
; Sub's 'value 'DTR

(setq EntData (entget Ent))
(setq InsPt (trans (value 10 EntData) 0 1))
(setq TxtJust (value 71 EntData))
(setq TxtWd (value 42 EntData))
(setq TxtHt (value 43 EntData))
(setq TxtRot (value 50 EntData))
(cond
((= TxtJust 2)
(setq InsPt (polar InsPt (+ (DTR 180) TxtRot) (/ TxtWd 2.0)))
)
((= TxtJust 3)
(setq InsPt (polar InsPt (+ (DTR 180) TxtRot) TxtWd))
)
((= TxtJust 4)
(setq InsPt (polar InsPt (+ (DTR 90) TxtRot) (/ TxtHt 2.0)))
)
((= TxtJust 5)
(setq InsPt (polar InsPt (+ (DTR 90) TxtRot) (/ TxtHt 2.0)))
(setq InsPt (polar InsPt (+ (DTR 180) TxtRot) (/ TxtWd 2.0)))
)
((= TxtJust 6)
(setq InsPt (polar InsPt (+ (DTR 90) TxtRot) (/ TxtHt 2.0)))
(setq InsPt (polar InsPt (+ (DTR 180) TxtRot) TxtWd))
)
((= TxtJust 7)
(setq InsPt (polar InsPt (+ (DTR 90) TxtRot) TxtHt))
)
((= TxtJust 8)
(setq InsPt (polar InsPt (+ (DTR 90) TxtRot) TxtHt))
(setq InsPt (polar InsPt (+ (DTR 180) TxtRot) (/ TxtWd 2.0)))
)
((= TxtJust 9)
(setq InsPt (polar InsPt (+ (DTR 90) TxtRot) TxtHt))
(setq InsPt (polar InsPt (+ (DTR 180) TxtRot) TxtWd))
)
(t
(setq InsPt InsPt)
)
)
(list
InsPt
(setq tmpPt (polar InsPt TxtRot TxtWd))
(polar tmpPt (+ (DTR 270) TxtRot) TxtHt)
(polar InsPt (+ (DTR 270) TxtRot) TxtHt)
)
)

--- End code ---

FengK:
Tim,

Thanks for your code! I'll look at it later. What I found is the height of grip has something to do with dxf group code 46, which is not documented in the DXF Reference.  When the value for group code 46 is changed, the height of grip is changed accordingly. But the BackgroundMask does not resize automatically.

Update:
The BackgroundMask is resized after close and re-open the drawing.

T.Willey:

--- Quote from: Kelie on February 05, 2008, 06:00:10 PM ---Tim,

Thanks for your code! I'll look at it later. What I found is the height of grip has something to do with dxf group code 46, which is not documented in the DXF Reference.  When the value for group code 46 is changed, the height of grip is changed accordingly. But the BackgroundMask does not resize automatically.


--- End quote ---
I have helped all I can.  :-)  I don't like mtext, and try not to use it, and I have never used a background mask, so I hope either you find out what needs to be done, or someone more knowledgeable than I will assist you.

FengK:
Tim, Yes I've solved my problem. All I had to do was set the value corresponding to group code 46 to 0.0. Something like (entmod (subst (cons 46 0.0) (assoc 46 ent) ent)) where ent is returned from ENTGET function applied to an ENAME. I had many MTEXT with Background Marks on and way too big. That's why I asked the question. 

As far as the code you posted, I can see what it does. But not sure about its usage. How will the info about actual bounding box be used? To draw a rectangle around the MTEXT?

Thanks again.

Navigation

[0] Message Index

[#] Next page

Go to full version