Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I asked CHATGPT for a lisp which would toggle the background mask of mtext between off and on with a border of 1.2, and I got the code below
I tried it and I got the following error
Select MText to toggle background mask: ; error: bad DXF group: (71 . 1.2)
Can anyone fix this so it will work in AutoCAD LT2025?
(defun c:ToggleMTextMask (/ ent mtext bgMask bgMargin)
;; Prompt user to select a single MText object
(setq ent (car (entsel "\nSelect MText to toggle background mask: ")))
(if (and ent (= "MTEXT" (cdr (assoc 0 (entget ent))))) ; Check if the entity is MText
(progn
(setq mtext (entget ent)) ; Get the entity data of the MText
;; Get current background mask status (bit 70)
(setq bgMask (cdr (assoc 70 mtext)))
;; Toggle the background mask (0 = off, 1 = on)
(if (= bgMask 1)
(progn
;; Turn the background mask off
(entmod (subst (cons 70 0) (assoc 70 mtext) mtext))
(princ "\nBackground mask turned off.")
)
(progn
;; Turn the background mask on and set margin to 1.2
(entmod (subst (cons 70 1) (assoc 70 mtext) mtext)) ; Turn mask on
(entmod (subst (cons 71 1.2) (assoc 71 mtext) mtext)) ; Set margin to 1.2
(princ "\nBackground mask turned on with margin of 1.2.")
)
)
)
(princ "\nSelected entity is not an MText object.")
)
(princ)
)
.
Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Solved! Go to Solution.