AutoLISP: Background Text Mask (Mtext Only)

Here is a quick way to turn on the text background to MTEXT. (Note: this routine works with MTEXT only.)

Click here to see how to add Background Text Mask to Dimensions and MLeaders as this routine does not allow for these objects.

here’s how:

  • TMASKON <enter> to turn on the text mask
  • TMASKOFF <enter> to turn off the text mask
  • Select the MTEXT objects
  • <enter> when finished selecting

;Maska Mtextu ano/ne - www.cadforum.cz

(defun C:TMaskOn (/ ss x ob1)

(vl-load-com)

(setq ss (ssget '((0 . "MTEXT"))))

(if ss

(mapcar '(lambda (x)

(setq ob1 (vlax-ename->vla-object x))

(if (= (vla-get-backgroundfill ob1) :vlax-false)

(vla-put-backgroundfill ob1 :vlax-true)

)

)

(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))

)

)

(prin1)

)

(defun C:TMaskOff (/ ss x ob1)

(vl-load-com)

(setq ss (ssget '((0 . "MTEXT"))))

(if ss

(mapcar '(lambda (x)

(setq ob1 (vlax-ename->vla-object x))

(if (= (vla-get-backgroundfill ob1) :vlax-true)

(vla-put-backgroundfill ob1 :vlax-false)

)

)

(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))

)

)

(prin1)

)

(defun C:TMaskOnOff (/ ss x ob1)

(vl-load-com)

(setq ss (ssget '((0 . "MTEXT"))))

(if ss

(mapcar '(lambda (x)

(setq ob1 (vlax-ename->vla-object x))

(if (= (vla-get-backgroundfill ob1) :vlax-true)

(vla-put-backgroundfill ob1 :vlax-false)

(vla-put-backgroundfill ob1 :vlax-true)

)

)

(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))

)

)

(prin1)

)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Modifying, Text. Bookmark the permalink.

3 Responses to AutoLISP: Background Text Mask (Mtext Only)

  1. Jon says:

    Hi,
    I have a LISP that generates an mtext entity, and I would like to use your tip to turn on the background mask immediately, rather than go back & turn it on in a second step. Can you show me what to change, if I provide the insert point of the text, or pass a “last” to your LISP?

    • AutoCAD Tips says:

      I think that you can add this lisp to the end of the other lisp and then take off the “C:” part of the defun “C:TMASKON” then prior to the ending (princ) or closing Parenthesis, you should be able to “Call” the text mask routine by adding a line with (TMASKON). There may be some adjusting of the parenthesis but that is normal…
      Unfortunately I don’t have much time to adjust it for you these days or I would gladly try it. If these steps don’t help. I would suggest posting at theswamp.org or cadtutor or even the Autodesk Autolips forums.

      Let me know if my suggestion help though.
      ~Greg

      • Jon says:

        your idea didn’t seem to work, however further study into your code showed me that what I really needed was just this: (vla-put-backgroundfill (vlax-ename->vla-object (entlast)) :vlax-true).
        So thanks much for your help!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s