Hope someone likes this thread and comment.
I want to resize selected mtext to fit its text value (text content), in order to use it for a lisp routine made to apply a background color fill to selected text, mtext and dimensions. Right now, it applies the background fill excellent, it was revised by Alan, and its a grest piece of work, but I think it can be even better if you add this function.
I can see that textmask.lsp uses a subfunction called "Acet-Geom-Textbox" stored in "acetutil.fas" to get text value geometry to assign a textbox, I would like to use the same function in this routine, but to re-assign (modify) the textbox to selected mtext objects.
I found a reference lisp (made by Cadmoogle) that converts text objects to mtext using this express function to assing the text box to selected text objects, in case you might want to check it out.
http://forums.cadalyst.com/showthread.php?t=5800
And here is the routine where I want to add this function, I just started to sort this new issue, so I am clueless right now.. I'll keep looking for samples.
The problem that you are going to hit... is that from Visual Lisp it is not exposed the MText Height property (the one available it is the height for the text objects).
Then you can only fix/update the Width (the one available for MText).
;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;;; + box_mtext +;;; + Created by C. Alan Butler +;;; + Copyright 2005 +;;; + by Precision Drafting & Design All Rights Reserved. +;;; + Contact at ab2draft@TampaBay.rr.com +;;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;;; ;;; VERSION ;;; 1.2 Jan 24, 2006 UCS corrections;;; ;;; FUNCTION ;;; Return Box coordinates for an Mtext object in any UCS, any angle. ;;; ;;; USAGE ;;; (box_mtext ent);;; ;;; ARGUMENTS ;;; ent = mtext ename;;; ;;; RETURNS;;; list of 4 points for box, (ll lr ur ul);;; ;;; PLATFORMS ;;; 2000+ Tested in 2000 only(defun box_mtext (ent / elst p10 txth ang vec wid hgt dxf UCSangle attpt ul ur lr ll) (defun dxf (code elst) (cdr (assoc code elst)) ) ;; incase it is a list, (ename point) (and (listp ent) (setq ent (car ent))) (setq elst (entget ent)) (setq p10 (trans (dxf 10 elst) 0 1) ; insertion point WCS to UCS txth (dxf 40 elst) ; text height wid (dxf 42 elst) ; full width hgt (dxf 43 elst) ; full height ang (dxf 50 elst) ; rotation angle in UCS attpt (dxf 71 elst) ; attachment point code ) ;|-------------------------------------------------------------- ;; CAB 01/24/2006 removed as the ang fron DXF code 50 os in UCS ;; correct for UCS (setq ang (- ang (angle (trans '(0.0 0.0 0.0) 1 0) (trans '(1.0 0.0 0.0) 1 0))) ) ;; angles 90 = (/ pi 2) 180 = pi 270 = (* pi 1.5) ---------------------------------------------------------------|; ;; Get upper left (ul) from insert point (p10) (cond ((= attpt 1) (setq ul p10)) ; top left ((= attpt 2) (setq ul (polar p10 (+ pi ang) (/ wid 2)))) ; top center ((= attpt 3) (setq ul(polar p10 (+ pi ang) wid))) ; top right ((= attpt 4) (setq ul (polar p10 (+ (/ pi 2) ang) (/ hgt 2)))) ; middle left ((= attpt 5) ; middle center (setq ul (polar (polar p10 (+ pi ang) (/ wid 2)) (+ (/ pi 2) ang) (+ (/ hgt 2))))) ((= attpt 6) ; middle right (setq ul (polar (polar p10 (+ pi ang) wid) (+ (/ pi 2) ang) (+ (/ hgt 2))))) ((= attpt 7) (setq ul (polar p10 (+(/ pi 2) ang) hgt))) ; bottom left ((= attpt ; bottom center (setq ul (polar (polar p10 (+ pi ang) (/ wid 2)) (+ (/ pi 2) ang) hgt))) ((= attpt 9) ; bottom right (setq ul (polar (polar p10 (+ pi ang) wid) (+ (/ pi 2) ang) hgt))) );cond (setq ur (polar ul ang wid) lr (polar ur (+ ang (* pi 1.5)) hgt) ll (polar lr (+ ang pi) wid) );setq (list ll lr ur ul));boxmtext
Well... I didn´t undestand it very well... I did some extra research and I accomplished something I wanted by just adding a few lines to original lisp
I wanted this routine to do as textmask do.. a mask adjusted to mtext value box... it actually uses a function to create a wipeout box (I think the function gets the text value size)
because when you have mtext objects with extra large boxes (grips, control points) you get an extra-sized mask...
I was under the impression that was required to fit the grips to the actual text paragraph width and height.
Have not tried any of the code posted so far - and do not know if by by having extracted the fit width and height it will allow to be updated by using subst and entmod from lisp - I know that from vlisp the width can be done.
I found the best routine fot this task in this thread, by Rogerio Brazil
http://discussion.autodesk.com/forums/thread.jspa?threadID=448625&tstart=0
and also Lee Mac's routine was good enough, but I wanted multiple selection, so I stood with Rogerio Brazil's routine ...
http://www.cadtutor.net/forum/showpost.php?p=230733&postcount=11
and the routine ended up like this... Special Thanks alan J. Thompson and Marco Jacinto for all their help.