<?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: Ribbon Icon Enable or Disable per document in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7387605#M97999</link>
    <description>&lt;P&gt;Thx a lot. This works. I was thinking the event on active documents would be as a document event. But actually it's an application event. I also referred to this site: &lt;A href="http://modthemachine.typepad.com/my_weblog/2013/07/inventor-events-using-net-3-examples.html" target="_blank"&gt;http://modthemachine.typepad.com/my_weblog/2013/07/inventor-events-using-net-3-examples.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now my button can be set to enable or disable depends on the property of the opening document.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Sep 2017 13:20:02 GMT</pubDate>
    <dc:creator>bwang-tecoustics</dc:creator>
    <dc:date>2017-09-18T13:20:02Z</dc:date>
    <item>
      <title>Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380477#M97992</link>
      <description>&lt;P&gt;Hi, I was able to follow Inventor SDK sample file to add custom buttons on the ribbon. Now I want the button to be Enable or Disable per a parameter of the active document. It's similar to the Inventor Copy and Cut buttons. When you select something, the buttons will be enable, otherwise it shows as disable. Any help will be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 12:47:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380477#M97992</guid>
      <dc:creator>bwang-tecoustics</dc:creator>
      <dc:date>2017-09-14T12:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380730#M97993</link>
      <description>&lt;P&gt;Hi, you should capture and react on Inventor's events. A good help is the EventWatcher. It helps you to find the correct events you have to react on and located in your SDK\DeveloperTools\Tools. The source code is included as well when you need an example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;P&gt;&lt;A href="http://etacad.de/" target="_blank"&gt;etaCAD.de&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 13:55:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380730#M97993</guid>
      <dc:creator>etaCAD</dc:creator>
      <dc:date>2017-09-14T13:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380967#M97994</link>
      <description>&lt;P&gt;Thx. I checked the EventWatchers and try to use the Document OnActive event&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Consolas" size="2"&gt;Private Sub m_docEvents_OnActive(BeforeOrAfter As EventTimingEnum, Context As NameValueMap, HandlingCode As HandlingCodeEnum) Handles m_docEvents.OnActivate&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I got an error says the method does not have a compatible signature with the original event. I can check the parameter and set the button to disable by clicking the button. But just can't initialize it when the document is loaded.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 14:53:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380967#M97994</guid>
      <dc:creator>bwang-tecoustics</dc:creator>
      <dc:date>2017-09-14T14:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380991#M97995</link>
      <description>&lt;P&gt;Also, after I added the document event handler, the add-in dll is not loaded. I think there are some handlers for the Ribbons only.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 15:00:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7380991#M97995</guid>
      <dc:creator>bwang-tecoustics</dc:creator>
      <dc:date>2017-09-14T15:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7382661#M97996</link>
      <description>&lt;P&gt;When your add-in doesn't load I think there is an error in your code. Perhaps you want connect to an document event when there isn't any open document yet. Without your code it is just like reading from a glass bowl for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;P&gt;&lt;A href="http://etacad.de/" target="_blank" rel="nofollow noopener noreferrer"&gt;etaCAD.de&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 07:25:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7382661#M97996</guid>
      <dc:creator>etaCAD</dc:creator>
      <dc:date>2017-09-15T07:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7383401#M97997</link>
      <description>&lt;P&gt;Here is part of my code. It's basicly copied from the sample. You can see I can set one of the button to disable (fourth last row). But I just don't know how to set it enable or disable dynamically depending a condition. Once I add a If statement, the add-in won't load.&lt;/P&gt;
&lt;PRE&gt;#Region "User interface definition"
        ' Sub where the user-interface creation is done.  This is called when
        ' the add-in loaded and also if the user interface is reset.
        Private Sub AddToUserInterface()
            ' This is where you'll add code to add buttons to the ribbon.

            '** Sample to illustrate creating a button on a new panel of the Tools tab of the Part ribbon.

            '** Sample to illustrate creating a button on a new panel of the Tools tab of the Assembly ribbon.
            ' Get the Assembly ribbon.
            Dim assmRibbon As Ribbon = g_inventorApplication.UserInterfaceManager.Ribbons.Item("Assembly")

            ' Get the "Tools" tab.
            Dim assmToolsTab As RibbonTab = assmRibbon.RibbonTabs.Item("id_TabTools")

            ' Create a new panel.
            Dim assmToolPanel As RibbonPanel = assmToolsTab.RibbonPanels.Add("BoMTool", "id_TECO_BoM_Tool", AddInClientID)

            ' Add a button.
            assmToolPanel.CommandControls.AddButton(asmBtnBomNorm, True)
            'asmBtnBomNorm.Enabled = Not (g_inventorApplication.ActiveDocument.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure)

            assmToolPanel.CommandControls.AddButton(asmBtnBomInsep, True)
            'asmBtnBomInsep.Enabled = Not (g_inventorApplication.ActiveDocument.ComponentDefinition.BOMStructure = BOMStructureEnum.kInseparableBOMStructure)
            'UpdateBoMButtons()

            '** Sample to illustrate creating a button on a new panel of the Tools tab of the Drawing ribbon.

            ' Get the Drawing ribbon.
            Dim dwgRibbon As Ribbon = g_inventorApplication.UserInterfaceManager.Ribbons.Item("Drawing")

            ' Get the "Tools" tab.
            'Dim dwgToolsTab As RibbonTab = dwgRibbon.RibbonTabs.Item("id_TabTools")
            Dim dwgAnnoteTab As RibbonTab = dwgRibbon.RibbonTabs.Item("id_TabAnnotate") ' Move the Buttons to under Annotation

            ' Create a new panel.
            Dim dwgAnnotePanel As RibbonPanel = dwgAnnoteTab.RibbonPanels.Add("TECO", "id_TECO_ToolBox", AddInClientID)

            ' Add a button.
            dwgAnnotePanel.CommandControls.AddButton(m_dwgBtnFind, True)
            dwgAnnotePanel.CommandControls.AddButton(m_dwgBtnSpell, True)
            m_dwgBtnSpell.Enabled = False


            'UpdateBoMButtons()
        End Sub&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Sep 2017 13:26:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7383401#M97997</guid>
      <dc:creator>bwang-tecoustics</dc:creator>
      <dc:date>2017-09-15T13:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7386683#M97998</link>
      <description>&lt;P&gt;Your code doesn't show how you capture and work on Inventor's events. Below is a rough pattern what you code structure should look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Class YourClassName

' Declare event
Private WithEvents m_ApplicationsEvents As Inventor.ApplicationEvents


Public Sub Activate(ByVal siteObj As Inventor.ApplicationAddInSite, ByVal loaded1stTime As Boolean) Implements ApplicationAddInServer.Activate

...

' Connect to the representations interface events
        m_ApplicationsEvents = siteObj.ApplicationEvents

...

'Creating the buttons

...

End Sub


' Reacting on events

 Private Sub m_ApplicationsEvents_OnActivateDocument(DocumentObject As _Document, _
                                                        BeforeOrAfter As EventTimingEnum, _
                                                        Context As NameValueMap, _
                                                        ByRef HandlingCode As HandlingCodeEnum) Handles m_ApplicationsEvents.OnActivateDocument
        If BeforeOrAfter = EventTimingEnum.kAfter Then
           ActivateOrDeactivateButtonAccordingToYourConditions()
        End If
 End Sub


End Class&lt;/PRE&gt;&lt;P&gt;Use the EventWatcher to look on which event you should have look on. I think you should focus on ApplicatonEvents and DocumentEvents. There are several examples in the SDK and have a look in the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 05:33:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7386683#M97998</guid>
      <dc:creator>etaCAD</dc:creator>
      <dc:date>2017-09-18T05:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Ribbon Icon Enable or Disable per document</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7387605#M97999</link>
      <description>&lt;P&gt;Thx a lot. This works. I was thinking the event on active documents would be as a document event. But actually it's an application event. I also referred to this site: &lt;A href="http://modthemachine.typepad.com/my_weblog/2013/07/inventor-events-using-net-3-examples.html" target="_blank"&gt;http://modthemachine.typepad.com/my_weblog/2013/07/inventor-events-using-net-3-examples.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now my button can be set to enable or disable depends on the property of the opening document.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 13:20:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ribbon-icon-enable-or-disable-per-document/m-p/7387605#M97999</guid>
      <dc:creator>bwang-tecoustics</dc:creator>
      <dc:date>2017-09-18T13:20:02Z</dc:date>
    </item>
  </channel>
</rss>

