<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Background mask toggle for MText in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366695#M2107</link>
    <description>&lt;P&gt;Would you post a sample dwg with 2 mtexts, with and without mask?&lt;/P&gt;</description>
    <pubDate>Wed, 12 Mar 2025 12:35:25 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2025-03-12T12:35:25Z</dc:date>
    <item>
      <title>Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366613#M2106</link>
      <description>&lt;P&gt;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&lt;/P&gt;
&lt;P&gt;I tried it and I got the following error&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Select MText to toggle background mask: ; error: bad DXF group: (71 . 1.2)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Can anyone fix this so it will work in AutoCAD LT2025?&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(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)
)&lt;/LI-CODE&gt;
&lt;P&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 11:52:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366613#M2106</guid>
      <dc:creator>h_s_walker</dc:creator>
      <dc:date>2025-03-12T11:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366695#M2107</link>
      <description>&lt;P&gt;Would you post a sample dwg with 2 mtexts, with and without mask?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 12:35:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366695#M2107</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2025-03-12T12:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366790#M2108</link>
      <description>&lt;P&gt;Drawing attached&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 13:12:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366790#M2108</guid>
      <dc:creator>h_s_walker</dc:creator>
      <dc:date>2025-03-12T13:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366799#M2109</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/65473"&gt;@h_s_walker&lt;/a&gt;&amp;nbsp;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ChatGPT almost hit the target&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;unfortunately classic lisp is not enough to turn on/off mtext background fill you need activex&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but to set the border offset factor (dxf code 45) you still need classic autolisp.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;check this ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;enjoy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Moshe&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:ToggleMTextMask (/ ent mtext bgMask bgMargin AcDbMText)
  ;; 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 AcDbMText (vlax-ename-&amp;gt;vla-object ent))

      ;; Get current background mask status (bit 70)
      (setq bgMask (vla-get-backgroundfill AcDbMText))
      
      ;; Toggle the background mask (0 = off, 1 = on)
      (if (eq bgMask :vlax-true)
        (progn
          ;; Turn the background mask off
	  (vla-put-backgroundfill AcDbMText :vlax-false)
          (princ "\nBackground mask turned off.")
        )
        (progn
          ;; Turn the background mask on and set margin to 1.2
	  (vla-put-backgroundfill AcDbMText :vlax-true)
          (setq mtext (entget ent))  ; Get the entity data of the MText
          (entmod (subst (cons 45 1.2) (assoc 45 mtext) mtext))  ; Set margin to 1.2
          (princ "\nBackground mask turned on with margin of 1.2.")
        )
      )
      (vlax-release-object AcDbMText)
    )
    (princ "\nSelected entity is not an MText object.")
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 13:18:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366799#M2109</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2025-03-12T13:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366815#M2110</link>
      <description>&lt;P&gt;Not sure if LT has (vla-xxx) functions, but perhaps it has (set/get-propertyvalue) functions - it was introuduced back with R 2012 AFAIK...&lt;/P&gt;&lt;P&gt;So, try this revision...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:ToggleMTextMask ( / ent mtext bgMask )

  ;; 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
      (if (= (getpropertyvalue ent "BackgroundFill") 1) ;|(assoc 45 mtext)|;
        (setq bgMask 1)
        (setq bgMask 0)
      )
      
      ;; Toggle the background mask (0 = off, 1 = on)
      (if (= bgMask 1)
        (progn
          ;; Turn the background mask off
          ;|
          (setq mtext (vl-remove (assoc 90 mtext) mtext))
          (setq mtext (vl-remove (assoc 63 mtext) mtext))
          (setq mtext (vl-remove (assoc 45 mtext) mtext))
          (setq mtext (vl-remove (assoc 441 mtext) mtext))
          (entupd (cdr (assoc -1 (entmod mtext))))
          |;
          (setpropertyvalue ent "BackgroundFill" 0)
          (princ "\nBackground mask turned off.")
        )
        (progn
          ;; Turn the background mask on and set margin to 1.2
          ;|
          (setq mtext (append mtext (list (cons 90 1))))
          (setq mtext (append mtext (list (cons 63 1))))
          (setq mtext (append mtext (list (cons 45 1.2))))  ; Set margin to 1.2
          (setq mtext (append mtext (list (cons 441 0))))
          (entupd (cdr (assoc -1 (entmod mtext))))
          |;
          (setpropertyvalue ent "BackgroundScaleFactor" 1.2)  ; Set margin to 1.2
          (setpropertyvalue ent "BackgroundFillColor" 1)  ; Set color to 1 = red
          (setpropertyvalue ent "BackgroundFill" 1)
          (princ "\nBackground mask turned on with margin of 1.2.")
        )
      )
    )
    (princ "\nSelected entity is not an MText object.")
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 13:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366815#M2110</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2025-03-12T13:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366838#M2111</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/52747"&gt;@Moshe-A&lt;/a&gt;&amp;nbsp;once again you've hit the mark&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 13:32:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366838#M2111</guid>
      <dc:creator>h_s_walker</dc:creator>
      <dc:date>2025-03-12T13:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366839#M2112</link>
      <description>&lt;P&gt;It's similar to &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/940934"&gt;@marko_ribar&lt;/a&gt;&amp;nbsp;apart from allowing to select multiple objects at the time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:ToggleMtextMask ( / s i e)

  (princ "\nSelect mtext to toogle background, ")
  (while (setq s (ssget ":S" '((0 . "MTEXT"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (if (= 0 (getpropertyvalue e "BackgroundFill"))
	(progn
	  (setpropertyvalue e "BackgroundFill" 1)
	  (setpropertyvalue e "BackgroundScaleFactor" 1.2)
	  (setpropertyvalue e "BackgroundTransparency" 0)
	  (setpropertyvalue e "UseBackgroundColor" 1)
	  (princ "\nBackground mask turned on."))
	(progn
	  (setpropertyvalue e "BackgroundFill" 0)
	  (princ "\nBackground mask turned off.")))))
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 13:33:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366839#M2112</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2025-03-12T13:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366854#M2113</link>
      <description>&lt;P&gt;mod to your code. mask color, if enabled, set to the background color.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:ToggleMTextMask (/ ent mtext bgMask)
  ;; 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 (group 90)
      (setq bgMask (cdr (assoc 90 mtext)))  
      
      ;; Toggle the background mask (0 = off, 1 = on)
      (if (or (null bgMask)(= 2 bgMask))
        	(progn
        	  ;; Turn the background mask on and set margin to 1.2
        	  (setq mtext (append mtext '((90 . 3))))  ; Turn mask on
        	  (entmod (append mtext '((45 . 1.2))))  ; Set margin to 1.2
        	  (princ "\nBackground mask turned on with margin of 1.2.")
        	)
        	(progn
        	  ;; Turn the background mask off
			  (vlax-put (vlax-ename-&amp;gt;vla-object ent) 'backgroundfill 0)
        	  (princ "\nBackground mask turned off.")
        	)
      )
    )
    (princ "\nSelected entity is not an MText object.")
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 13:46:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366854#M2113</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2025-03-12T13:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366912#M2114</link>
      <description>&lt;P&gt;If you wanted to see how promising your attempt at using GPTChat was...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;GPT tested for the existence of a background based on the code &lt;STRONG&gt;70&lt;/STRONG&gt;... in fact it is 90 and 70 is undefined.&lt;BR /&gt;It set the offset margin with the code &lt;STRONG&gt;71&lt;/STRONG&gt;... in fact it is 45. 71 defines the text alignment.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-5E5DB93B-F8D3-4433-ADF7-E92E250D2BAB" target="_blank" rel="noopener"&gt;HELP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How much time did you spend on it? No change to succeed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(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 &lt;STRONG&gt;70&lt;/STRONG&gt; mtext)))  
      
      ;; Toggle the background mask (0 = off, 1 = on)
      (if (= bgMask 1)
        (progn
          ;; Turn the background mask off
          (entmod (subst (cons &lt;STRONG&gt;70&lt;/STRONG&gt; 0) (assoc &lt;STRONG&gt;70&lt;/STRONG&gt; mtext) mtext))
          (princ "\nBackground mask turned off.")
        )
        (progn
          ;; Turn the background mask on and set margin to 1.2
          (entmod (subst (cons &lt;STRONG&gt;70&lt;/STRONG&gt; 1) (assoc &lt;STRONG&gt;70&lt;/STRONG&gt; mtext) mtext))  ; Turn mask on
          (entmod (subst (cons &lt;STRONG&gt;71&lt;/STRONG&gt; 1.2) (assoc &lt;STRONG&gt;71&lt;/STRONG&gt; 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)
)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:07:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366912#M2114</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2025-03-12T14:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366928#M2115</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;&amp;nbsp;No time. I don't know lisp, so I asked CHATGPT to create it for me&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:13:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366928#M2115</guid>
      <dc:creator>h_s_walker</dc:creator>
      <dc:date>2025-03-12T14:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366931#M2116</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe ChatGPT creators did not have the time to update their knowledge database?!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:14:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366931#M2116</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2025-03-12T14:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Background mask toggle for MText</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366983#M2117</link>
      <description>&lt;P&gt;Then there is no value in trying to fix that mess. It's just more efficient to start from scratch. That's what I thought.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 14:30:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/background-mask-toggle-for-mtext/m-p/13366983#M2117</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2025-03-12T14:30:24Z</dc:date>
    </item>
  </channel>
</rss>

