entmod to remove MText background

entmod to remove MText background

janis.prodnieks
Advocate Advocate
364 Views
1 Reply
Message 1 of 2

entmod to remove MText background

janis.prodnieks
Advocate
Advocate

I'm trying to remove background mask from MText using entmod and am stuck a bit. If I use the example provided in entmod help article, it works. If I try to adjust it slightly to change Background mask setting instead of changing layer, it doesn't work. What am I missing?

 

The shortened piece of code, intended to make the entmod working. Before running the script a MText with a background should be made (or existing MText should be copied) so with entlast function a MText with background on would be retrieved:

(defun c:RemoveBackgroundMaskFromMText (/ ss i ent ed) ;ss = Selection Set, i = counter, ent = Entity, ed = Entity Data
(setq ent (entlast))
(setq ed (entget ent))
;(setq ed (subst (cons 8 "1") (assoc 8 ed) ed )) ;<-- This line is copied from Help sample, it works if next line is disabled
(setq ed (subst (cons 90 0) (assoc 90 ed) ed))
(entmod ed)
)
0 Likes
365 Views
1 Reply
Reply (1)
Message 2 of 2

hosneyalaa
Advisor
Advisor

 

@janis.prodnieks 

see this

 

;;  https://adndevblog.typepad.com/autocad/2013/05/change-the-background-mask-property-of-acdbmtext-object-programmatically-using-objectarx.html
(defun toggleBackgroundMaskOfAMText (en / ed)
  (setq ed (entget en))   ; Sets ed to the entity data
  (setq atom90 (assoc 90 ed))
  (if (= atom90 nil)
    ;; no 90 groud code at all
    (progn
      (setq lst90 (cons 90 1))
      (setq atom63 (cons 63 1))
      (setq ed (append ed (list atom63 lst90)))
      ;; Add the 63 group code to set the background color as 1 (RED)
    )
    (progn
      (setq maskProp (cdr atom90))
      (if (= (boole 1 maskProp 1) 1)
(setq new90 (cons 90 2))
(setq new90 (cons 90 1))
      )
      (setq ed
      (subst new90
      (assoc 90 ed) ; Toggle the value of 90 group in ed.
      ed
      )
      )
    )
  )

  (entmod ed)
  (princ)
)

(defun c:testBGMask ()
  (toggleBackgroundMaskOfAMText
    (car (entsel))
  )
)

0 Likes