Hey all, in my application inc Civil 3D I often run into a problem with large mtext notes, even with the reference rectangle set to 0's the text mask takes up too much page real estate, leaving chunks needlessly wiped out. I had been exploding the mtext, converting the individual lines of dtext to mtext, tweaking it back into place and turning on the text mask. I knew there had to be a better way, so I banged out this little routine yesterday. Seems to be working fine, though i have run into a slight left-to-right shift with some True Type fonts and a more noticeable shift with oblique text, also some special characters get messed up, but still much faster than previous for me.
anyways here's the code, use it if you want, comment or critique it if you want, or ignore if you don't care. I just thought I'd share.
Code:
; TightTextMask v1.0 CCalder May, 2013
; Permission to use, copy, modify, and distribute this software
; for any purpose and without fee is hereby granted
; Prompts user to select an mtext object. Explodes mtext and
; creates a new mtext object for each line of dtext with text
; mask turned on sometimes will shift text l or r if text is
; oblique, but usually text doesn't move
(defun c:TTM (/) (c:TightTextMask)) ;shortcut
(defun c:TightTextMask ( / en:mt en:dt en1 en2 en3 en4 cnt )
(princ "\nSelect MText to Tight Mask: ")
(setq en:mt (ssname (ssget "_:s" '((0 . "mtext"))) 0) )
(command "explode" en:mt)
(setq en:dt (ssget "_P"))
(setq cnt 0)
(repeat (sslength en:dt)
(setq en1 (entget (ssname en:dt cnt)))
(setq en2 (cdr (assoc 10 en1)))
(setq en3 (cdr (assoc 40 en1)))
(setq en4 (list (car en2) (+ (cadr en2) en3) (caddr en2)))
(entmake
(list
(cons 0 "MTEXT")
(cons 100 "AcDbEntity")
(assoc 8 en1)
(cons 100 "AcDbMText")
(cons 10 en4)
(assoc 40 en1)
(cons 41 0.0)
(cons 46 0.0)
(cons 71 1)
(cons 72 5)
(assoc 1 en1)
(assoc 7 en1)
(assoc 50 en1)
(cons 73 2)
(cons 90 3)
(cons 63 9)
(cons 45 1.35))
)
(setq cnt (+ 1 cnt))
)
(command "erase" en:dt)
(PRINC)
)
(princ "\n TightTextMask v1.0 \n CCalder, \nMay, 2013....loaded.")
(terpri)
(princ "Type \"TTM\" or \"TightTextMask\" to run")
(print)