I remember doing this not to long ago here. Someone else posted the same
thing. Maybe if you search you can find the post. I don't use mtext, so I
don't know how helpful I can be after what I have posted already, and I'm
still on 2004. Sorry.
--
Tim
"A blind man lets nothing block his vision."
wrote in message news:5056336@discussion.autodesk.com...
Tim,
Thanks, but this doesn't work for me in 2006. It sets the width, but the
height doesn't change. Also, I see no change in DXF 43 when I resize an
MText box. Odd...
-Brent McAnney
"T.Willey" wrote in message
news:5056189@discussion.autodesk.com...
See if this works for you.
[code]
(defun c:ChangeMtextBox (/ temp1 Ent)
(if (setq temp1 (GetMTextBB (setq Ent (car (entsel "\n Select Mtext: ")))))
(progn
(if (equal (caar temp1) (caadr temp1) 0.0001)
(progn
(entmod (subst (cons 43 (distance (car temp1) (cadr temp1))) (assoc 43
(entget Ent)) (entget Ent)))
(entmod (subst (cons 41 (distance (car temp1) (caddr temp1))) (assoc 41
(entget Ent)) (entget Ent)))
)
(progn
(entmod (subst (cons 43 (distance (car temp1) (caddr temp1))) (assoc 43
(entget Ent)) (entget Ent)))
(entmod (subst (cons 41 (distance (car temp1) (cadr temp1))) (assoc 41
(entget Ent)) (entget Ent)))
)
)
)
)
(princ)
)
;---------------------------------------------------------------------
(defun GetMTextBB (Ent / EntData EnsPt TxtJust TxtWd TxtHt TxtRot LeftX
RightX TopY BottomY Oldos RtnList 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 (value 10 EntData))
(setq TxtJust (value 71 EntData))
(setq TxtWd (value 42 EntData))
(setq TxtHt (value 43 EntData))
(setq TxtRot (value 50 EntData))
(setq Oldos (getvar "osmode"))
(setvar "osmode" 0)
(command "_.ucs" "_3" InsPt (polar InsPt TxtRot 0.001) (polar InsPt (+ (DTR
90) TxtRot) 0.001))
(setq InsPt (trans (value 10 (entget Ent)) 0 1))
(setq TxtRot (value 50 (entget Ent)))
(cond
((or (= TxtJust 1) (= TxtJust 4) (= TxtJust 7))
(setq LeftX (car InsPt))
(setq RightX (car (polar InsPt TxtRot TxtWd)))
)
((or (= TxtJust 2) (= TxtJust 5) (= TxtJust 8))
(setq LeftX (car (polar InsPt TxtRot (/ TxtWd 2))))
(setq RightX (car (polar InsPt (+ (DTR 180) TxtRot) (/ TxtWd 2))))
)
((or (= TxtJust 3) (= TxtJust 6) (= TxtJust 9))
(setq LeftX (car (polar InsPt (+ (DTR 180) TxtRot) TxtWd)))
(setq RightX (car InsPt))
)
)
(cond
((or (= TxtJust 1) (= TxtJust 2) (= TxtJust 3))
(setq TopY (cadr InsPt))
(setq BottomY (cadr (polar InsPt (+ (DTR 270) TxtRot) TxtHt)))
)
((or (= TxtJust 4) (= TxtJust 5) (= TxtJust 6))
(setq TopY (cadr (polar InsPt (+ (DTR 90) TxtRot) (/ TxtHt 2))))
(setq BottomY (cadr (polar InsPt (+ (DTR 270) TxtRot) (/ TxtHt 2))))
)
((or (= TxtJust 7) (= TxtJust 😎 (= TxtJust 9))
(setq TopY (cadr (polar InsPt (+ (DTR 90) TxtRot) TxtHt)))
(setq BottomY (cadr InsPt))
)
)
(setvar "osmode" Oldos)
(setq RtnList (mapcar '(lambda (a) (trans a 1 0)) (list (list LeftX BottomY)
(list RightX BottomY) (list RightX TopY) (list LeftX TopY))))
(command "_.ucs" "_p")
(setq RtnList (mapcar '(lambda (a) (trans a 0 1)) RtnList))
)
;---------------------------------------------------------------------------
-----
(defun DTR (a) ;Degrees to radians conversion
(* pi (/ a 180.0)))
;---------------------------------------------------------------------------
---------
(defun VALUE (num ent /)
(cdr (assoc num ent))
)
[/code]
--
Tim
"A blind man lets nothing block his vision."
wrote in message news:5056121@discussion.autodesk.com...
Hello,
I would like to write a routine to resize the MText limits box to the
minimum size required to cover the text, for background masking purposes.
From the DXF codes, I see that I can simply set code 41 to match code 42 in
order to set the width. However, I cannot seem to figure out how the
vertical dimension is defined. (entget) shows no change in the DXF codes
after I resize the mtext box.
I do know how to figure out the height that I need, using
(acet-geom-textbox), but I can't seem to figure out how to apply this height
the MText entity. Anyone know?
Thanks!
-Brent McAnney