CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.094.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator. New AutoCAD 2026 commands and variables.
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closedmtext background mask auto-fit

 Post Reply Post Reply
Author
germanbarry View Drop Down
Groupie
Groupie


Joined: 14.Apr.2011
Location: Germany
Using: AutoCAD 2011
Status: Offline
Points: 33
Direct Link To This Post Topic: mtext background mask auto-fit
    Posted: 09.May.2011 at 14:16
anyone know of a lisp which lets you select one or many MTEXT entities and have the background mask "hug" the text nice and snugly on say one line of text as default?
 
in an attempt to clarify: you can insert some MTEXT and it might only be 3 letters long but if the mtext box you traced before typing in the text was huge, and the MTEXT has a background mask/BGM, and is also at the front of your draw order, then that text BGM will be acting like a wipeout for the unused portion of its extents.
 
I am hoping to find a lisp which will auto-size the mtext to hug the text nicely (similarly to what microsoft excel does to columns when you double-click on the edge of a column heading/name)
 
obviously this lisp wouldnt apply if you have lots of MTEXTs going over multiple rows/lines within the single MTEXT entity and you want it to stay that way - this lisp would be most ideal for single-line MTEXT scenarios
Back to Top
alanjt View Drop Down
Groupie
Groupie


Joined: 08.Apr.2009
Location: United States
Using: Civil 3D 2009/2011
Status: Offline
Points: 30
Direct Link To This Post Posted: 13.May.2011 at 04:59
The background mask limits (plus the defined offset) are defined by the width of the MText object. Just set the MText to have a width of zero. Here's a LISP I wrote a while back for doing that very thing. Unless I'm typing notes in paperspace, I create all MText with a zero width (even have a LISP macro to avoid having to specify a zero width each time).

(defun c:WD (/ ss wd)
  ;; Change width of selected MText and MultiLeader objects
  ;; Alan J. Thompson, 11.05.09
  (vl-load-com)
  (if (and (setq ss (ssget "_:L" '((0 . "MTEXT,MULTILEADER"))))
           (setq wd (initget 4)
                 wd (cond ((getdist "\nWidth <0.0>: "))
                          (0.)
                    )
           )
      )
    (progn
      (vlax-for x (setq ss (vla-get-activeselectionset
                             (cond (*AcadDoc*)
                                   ((setq *AcadDoc* (vla-get-activedocument
                                                      (vlax-get-acad-object)
                                                    )
                                    )
                                   )
                             )
                           )
                  )
        (vl-catch-all-apply
          (function vlax-put-property)
          (list x
                (cond ((eq (vla-get-objectname x) "AcDbMText") 'Width)
                      ((eq (vla-get-objectname x) "AcDbMLeader") 'TextWidth)
                )
                wd
          )
        )
      )
      (vla-delete ss)
    )
  )
  (princ)
)



Edited by alanjt - 13.May.2011 at 04:59
Back to Top
alanjt View Drop Down
Groupie
Groupie


Joined: 08.Apr.2009
Location: United States
Using: Civil 3D 2009/2011
Status: Offline
Points: 30
Direct Link To This Post Posted: 13.May.2011 at 05:01
Oh yeah, here's the MText LISP macro I use to place MText with a zero width. The really nice thing is, you can right-click/enter at the first getpoint prompt and you'll be able to place MText with a defined width.

; mtext with 0 width
(defun c:T (/ pt)
  (initdia)
  (command "_.mtext")
  (if (setq pt (getpoint "\nSpecify insertion point <First corner>: "))
    (command "_non" pt "_W" 0.)
  )
  (princ)
)

Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,189 seconds.