<?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: Toggle LWDISPLAY system variable in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257570#M58583</link>
    <description>&lt;P&gt;That was the solution.&lt;/P&gt;&lt;P&gt;My thanks to you and also Alfred and &amp;amp; Hallex.&lt;/P&gt;&lt;P&gt;Sorry for the trouble.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Dec 2011 19:33:51 GMT</pubDate>
    <dc:creator>SRSDS</dc:creator>
    <dc:date>2011-12-09T19:33:51Z</dc:date>
    <item>
      <title>Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3211796#M58574</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can someone suggest why I would get an eInvalidInput error when toggling &amp;nbsp;a system variable.&lt;/P&gt;&lt;P&gt;I've tried a few things which is why it's 4 lines instead of 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        Dim lwdisplay As Object = Application.GetSystemVariable("LWDISPLAY")
        If CShort(lwdisplay) = 0 Then
            Application.SetSystemVariable("LWDISPLAY", CShort(1))
        End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;It generally works but every so often produces an error and I can't figure out why.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2011 03:01:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3211796#M58574</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2011-11-01T03:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3211882#M58575</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;at least the question is the line ... in which line does your code throw an exception?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And for doing that in one line ... use this (but it's not faster and it's not easier to read):&lt;/P&gt;&lt;PRE&gt;   &amp;lt;Runtime.CommandMethod("ADESK_ToggleLWDisp")&amp;gt; _
   Public Shared Sub ADESK_ToggleLWShow()
      Application.SetSystemVariable("LWDISPLAY", Math.Abs(CType(Application.GetSystemVariable("LWDISPLAY"), Integer) - 1))
   End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;this command I have tried (many times) with 2010/32bit, 2010/64bit, 2012/64bit and I could not reproduce a crash. The difference might be that I run that from a command?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2011 06:40:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3211882#M58575</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2011-11-01T06:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256032#M58576</link>
      <description>&lt;P&gt;Hi Alfred,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must have forgotten to look into this but have rediscoverd the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even using&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        Dim lwdisplay As Object = Application.GetSystemVariable("LWDISPLAY")
        If CShort(lwdisplay) = 0 Then
            Application.SetSystemVariable("LWDISPLAY", Math.Abs(CType(Application.GetSystemVariable("LWDISPLAY"), Integer) - 1))
        End If&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I still get an eInvalidInput error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems like a basic toggle. 2011/32bit here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2011 20:37:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256032#M58576</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2011-12-08T20:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256052#M58577</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.... your code is not the same I wrote, your code just turns ON LWDISPLAY but never OFF.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What line does crash? What message do you get as Exception.Message? Have you tried my command exactly in the way I prepared it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2011 20:42:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256052#M58577</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2011-12-08T20:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256110#M58578</link>
      <description>&lt;P&gt;It should do the same I would have thought. If 0 the abs(-1) should turn it on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            Try
                Application.SetSystemVariable("LWDISPLAY", CInt(1))
            Catch
                Try
                    Application.SetSystemVariable("LWDISPLAY", CShort(1))
                Catch
                    Try
                        Application.SetSystemVariable("LWDISPLAY", CBool(1))
                    Catch
                        MsgBox("?")
                    End Try
                End Try
            End Try&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I get either eInvalidInput or "Value does not fall within the expected range".&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2011 21:21:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256110#M58578</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2011-12-08T21:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256170#M58579</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; It should do the same I would have thought. If 0 the abs(-1) should turn it on&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;My code did toogle LWDISPLAY, if it's 0 then I turn it to 1, if it's one I change it to 0.&lt;/P&gt;&lt;P&gt;Your previous code had an if LWDISPLAY = 0 then included, so if LWDISPLAY was 1 there was never changed back to 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, that's not the problem at the moment. Your code never works? Let me know what AutoCAD you exactly have now:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;AutoCAD .... or vertical Product (like Mech, Map3D, Civil3D, ...)&lt;/LI&gt;&lt;LI&gt;what release?&lt;/LI&gt;&lt;LI&gt;32bit/64bit?&lt;/LI&gt;&lt;LI&gt;what servicepack is installed&lt;/LI&gt;&lt;LI&gt;what version of VisualStudio do you have?&lt;/LI&gt;&lt;LI&gt;what Framework does your App use?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;...maybe we get any info that gives us a chance to work on/to check.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2011 21:50:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256170#M58579</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2011-12-08T21:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256854#M58580</link>
      <description>&lt;P&gt;How about avoid using VBA-like types&lt;/P&gt;&lt;PRE&gt;        Public Sub togglelwdisplay()


            Dim lwdisplay As Short = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("LWDISPLAY")


            If lwdisplay = 0 Then


                Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("LWDISPLAY", 1)


            Else


                Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("LWDISPLAY", 0)


            End If


        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;VBA-like types:&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;</description>
      <pubDate>Fri, 09 Dec 2011 13:15:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3256854#M58580</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2011-12-09T13:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257054#M58581</link>
      <description>&lt;P&gt;I think it's got something to do with using code in a palette.&lt;/P&gt;&lt;P&gt;It works fine when I move it to &amp;nbsp;the initialize component.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is a VERY simple example of what I'm experiencing if someone's got time to look.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 14:55:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257054#M58581</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2011-12-09T14:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257430#M58582</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it works in the Iniitialize component and not in&amp;nbsp;a palette, it usually means your having a problem with the contexts (application/document contexts). Can you please try locking the active document in the palette code before you try to change the variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;code&amp;gt;&lt;/P&gt;
&lt;P&gt;using(DocumentLock lk = Application.DocumentManager.MdiActiveDocument.LockDocument())&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Do your thing&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;lt;/code&amp;gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 18:28:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257430#M58582</guid>
      <dc:creator>gopinath.taget</dc:creator>
      <dc:date>2011-12-09T18:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle LWDISPLAY system variable</title>
      <link>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257570#M58583</link>
      <description>&lt;P&gt;That was the solution.&lt;/P&gt;&lt;P&gt;My thanks to you and also Alfred and &amp;amp; Hallex.&lt;/P&gt;&lt;P&gt;Sorry for the trouble.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2011 19:33:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toggle-lwdisplay-system-variable/m-p/3257570#M58583</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2011-12-09T19:33:51Z</dc:date>
    </item>
  </channel>
</rss>

