This code will toggle on both Background Mask and Frame Text
(defun c:BGtoggle (/ ss1 num cnt get_dst BGoffSet obj ent data elist mtwidth)
(setq ss1 (ssget '((0 . "mtext,text")))
num (sslength ss1)
cnt 0
)
(repeat num
(if (eq (cdr (assoc 0 (entget (setq ent (ssname ss1 cnt))))) "TEXT")
(progn (command "_.txt2mtxt" ent "")
(entmod (subst '(41 . 0.) (assoc 41 (setq data (entget (setq ent (entlast))))) data))
)
)
(setq obj (vlax-ename->vla-object ent))
(if (= (vlax-get-property obj 'BackgroundFill) :vlax-true)
(vlax-put-property obj 'BackgroundFill :vlax-false)
(progn
(vlax-put-property obj 'BackgroundFill :vlax-true)
(if (= get_dst BGoffSet nil)
(progn
(or ·×BGoff×· (setq ·×BGoff×· 1.15))
(setq get_dst (getreal (strcat"\nEnter Distance :<" (rtos ·×BGoff×·) "> ")))
(if get_dst (setq ·×BGoff×· get_dst))
(setq BGoffSet "T")
)
)
(setq ent (vlax-vla-object->ename obj)
elist (entget ent)
elist (subst (cons 90 19)(assoc 90 elist) elist) ;Use drawing background color
elist (subst (cons 45 ·×BGoff×·) (assoc 45 elist) elist) ;Set 'Border Offset Factor'
mtwidth (* (cdr (assoc 42 elist))1.015)
elist (subst (cons 41 mtwidth)(assoc 41 elist) elist) ;Trim excess width
)
(entmod elist)
) ; progn
)
(setq cnt (1+ cnt))
) ; repeat
(vl-cmdf "_draworder" ss1 "" "f")
(princ)
)
64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter