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) )
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?
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
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!