<?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: Dynamically controlling menu content in a cui in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207390#M20561</link>
    <description>Here is the example from help for using the Application Level SysVarChanged Event. The system variable you need is WSCURRENT.&lt;BR /&gt;
&lt;BR /&gt;
Public WithEvents ACADApp As AcadApplication    ' Use with Application Event Examples&lt;BR /&gt;
Sub Example_AcadApplication_Events()&lt;BR /&gt;
    ' This example intializes the public variable (ACADApp) which will be used&lt;BR /&gt;
    ' to intercept AcadApplication Events&lt;BR /&gt;
    '&lt;BR /&gt;
    ' The VBA WithEvents statement makes it possible to intercept an generic object&lt;BR /&gt;
    ' with the events associated with that object.&lt;BR /&gt;
    '&lt;BR /&gt;
    ' Before you will be able to trigger any of the AcadApplication events,&lt;BR /&gt;
    ' you will first need to run this procedure.&lt;BR /&gt;
    &lt;BR /&gt;
    ' We could get the application from the ThisDocument object, but that would&lt;BR /&gt;
    ' require having a drawing open, so we grab it from the system.&lt;BR /&gt;
    Set ACADApp = GetObject(, "AutoCAD.Application.16")&lt;BR /&gt;
End Sub&lt;BR /&gt;
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)&lt;BR /&gt;
    ' This example intercepts an Application SysVarChanged event.&lt;BR /&gt;
    '&lt;BR /&gt;
    ' This event is triggered when the value of a system variable is changed.&lt;BR /&gt;
    '&lt;BR /&gt;
    ' To trigger this example event:&lt;BR /&gt;
    '     1) Make sure to run the example that initializes&lt;BR /&gt;
    '     the public variable (named ACADApp) linked to this event.&lt;BR /&gt;
    '&lt;BR /&gt;
    '     2) Change the value of a system variable in AutoCAD.&lt;BR /&gt;
    '     For example: Type GRIDMODE on the command line and toggle the grid display on/off&lt;BR /&gt;
&lt;BR /&gt;
    ' Use the "SysvarName" and "newVal" variables to determine which&lt;BR /&gt;
    ' system variable has changed and its new value.&lt;BR /&gt;
    MsgBox "The system variable " &amp;amp; SysvarName &amp;amp; " was just changed to: " &amp;amp; newVal&lt;BR /&gt;
End Sub</description>
    <pubDate>Mon, 17 Mar 2008 21:23:43 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-03-17T21:23:43Z</dc:date>
    <item>
      <title>Dynamically controlling menu content in a cui</title>
      <link>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207389#M20560</link>
      <description>I have VBA code which controls just how much of a custom drop down menu is displayed. Basically the VBA code presents 4 menu items by default when the user starts a new drawing or opens an existing one. Then, dependent on the existence of an identification block will also display a further 12 items. This has worked well since I developed it for v2000 (we're currently using v2005).&lt;BR /&gt;
&lt;BR /&gt;
However we are migrating to 2008 and, whilst the code still works at drawing creation and opening, when the user changes workspace the  menu disappears. I can't find a reactor that will trigger when the workspace changes so I can only think that I will have to create the menu dropdown in an Enterprise cui to make sure it stays on screen.&lt;BR /&gt;
&lt;BR /&gt;
But can anyone advise how I can duplicate the testing for the identification block to control menu item display in the cui?</description>
      <pubDate>Mon, 17 Mar 2008 20:44:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207389#M20560</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-17T20:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically controlling menu content in a cui</title>
      <link>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207390#M20561</link>
      <description>Here is the example from help for using the Application Level SysVarChanged Event. The system variable you need is WSCURRENT.&lt;BR /&gt;
&lt;BR /&gt;
Public WithEvents ACADApp As AcadApplication    ' Use with Application Event Examples&lt;BR /&gt;
Sub Example_AcadApplication_Events()&lt;BR /&gt;
    ' This example intializes the public variable (ACADApp) which will be used&lt;BR /&gt;
    ' to intercept AcadApplication Events&lt;BR /&gt;
    '&lt;BR /&gt;
    ' The VBA WithEvents statement makes it possible to intercept an generic object&lt;BR /&gt;
    ' with the events associated with that object.&lt;BR /&gt;
    '&lt;BR /&gt;
    ' Before you will be able to trigger any of the AcadApplication events,&lt;BR /&gt;
    ' you will first need to run this procedure.&lt;BR /&gt;
    &lt;BR /&gt;
    ' We could get the application from the ThisDocument object, but that would&lt;BR /&gt;
    ' require having a drawing open, so we grab it from the system.&lt;BR /&gt;
    Set ACADApp = GetObject(, "AutoCAD.Application.16")&lt;BR /&gt;
End Sub&lt;BR /&gt;
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)&lt;BR /&gt;
    ' This example intercepts an Application SysVarChanged event.&lt;BR /&gt;
    '&lt;BR /&gt;
    ' This event is triggered when the value of a system variable is changed.&lt;BR /&gt;
    '&lt;BR /&gt;
    ' To trigger this example event:&lt;BR /&gt;
    '     1) Make sure to run the example that initializes&lt;BR /&gt;
    '     the public variable (named ACADApp) linked to this event.&lt;BR /&gt;
    '&lt;BR /&gt;
    '     2) Change the value of a system variable in AutoCAD.&lt;BR /&gt;
    '     For example: Type GRIDMODE on the command line and toggle the grid display on/off&lt;BR /&gt;
&lt;BR /&gt;
    ' Use the "SysvarName" and "newVal" variables to determine which&lt;BR /&gt;
    ' system variable has changed and its new value.&lt;BR /&gt;
    MsgBox "The system variable " &amp;amp; SysvarName &amp;amp; " was just changed to: " &amp;amp; newVal&lt;BR /&gt;
End Sub</description>
      <pubDate>Mon, 17 Mar 2008 21:23:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207390#M20561</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-17T21:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically controlling menu content in a cui</title>
      <link>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207391#M20562</link>
      <description>Thankyou Nathan, never thought of that. Works a treat.</description>
      <pubDate>Tue, 18 Mar 2008 09:23:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207391#M20562</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-18T09:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically controlling menu content in a cui</title>
      <link>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207392#M20563</link>
      <description>I spoke too soon! It works on starting a fresh drawing but the moment I run any code from the menu I add this way - basically setting up the drawing, adding frame etc - it stops working and the sysvarchanged stops being triggered.&lt;BR /&gt;
&lt;BR /&gt;
Delving through the help files I see that the GetObject function only returns the first instance of AutoCAD. Whilst not actually opening a 2nd instance I am running in multiple interface mode. Can this be causing the problem? If it is I need to find some way around the problem (other than running in single).&lt;BR /&gt;
&lt;BR /&gt;
If I manually rerun the application_events sub then it works again but I don't seem to be able to re-run it programatically.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas? My brains melting111111</description>
      <pubDate>Wed, 16 Apr 2008 10:49:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/dynamically-controlling-menu-content-in-a-cui/m-p/2207392#M20563</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-04-16T10:49:27Z</dc:date>
    </item>
  </channel>
</rss>

