<?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: AddIn event on document change in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867818#M82197</link>
    <description>&lt;P&gt;@&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate"&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3093852" target="_self"&gt;&lt;SPAN class=""&gt;SutherNe&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt; Solution is almost comlete only one small thing that you need set oAppevents&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best way to add it in addin activate method :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;g_inventorApplication = addInSiteObject.Application&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oAppevents= g_inventorApplication.ApplicationEvents()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dont forget to declare g_inventorApplication like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public g_inventorApplication As Inventor.Application&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or use your own object for inventor...&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2018 11:20:35 GMT</pubDate>
    <dc:creator>marcin_otręba</dc:creator>
    <dc:date>2018-03-20T11:20:35Z</dc:date>
    <item>
      <title>AddIn event on document change</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/6299765#M63620</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm writing an addin that works with iProperties of the active document or the selected document. But I can't find the right event to trigger my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have now is 2 events,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first when the user selects an item (in assembly)&amp;nbsp; this works fine for me.&lt;/P&gt;&lt;PRE&gt;' Add event handler for user selected object event
m_UserInputEvent = m_inventorApplication.CommandManager.UserInputEvents
AddHandler m_UserInputEvent.OnSelect AddressOf OnDocumentChangeEvent&lt;/PRE&gt;&lt;P&gt;But I want also an event when the user changes document open or switches active document on the bottom with tabs.&lt;/P&gt;&lt;PRE&gt;' Add event handler for OnDocumentChange event.
m_AppEvents = m_inventorApplication.ApplicationEvents
AddHandler m_AppEvents.OnActivateDocument, AddressOf OnDocumentChangeEvent&lt;/PRE&gt;&lt;P&gt;This second event fires more than I like, on open document 2x and on other unwanted moments. What event can I use for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 06:55:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/6299765#M63620</guid>
      <dc:creator>Jef_E</dc:creator>
      <dc:date>2016-04-29T06:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn event on document change</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/6367668#M64438</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is how I add event triggers to the standardAddInServer:&lt;/P&gt;&lt;P&gt;at the start of the namespace i add the line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Private WithEvents oAppEvents As ApplicationEvents&lt;/PRE&gt;&lt;P&gt;as shown:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Public Class StandardAddInServer
        Implements Inventor.ApplicationAddInServer
        'Application events object
        Private WithEvents oAppEvents As ApplicationEvents&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This means I can them select oAppEvents from the left dropdown above yor code window, and from the right one you have a full set of event triggers ready. to use.&lt;/P&gt;&lt;P&gt;I Can then choose OnActivateDocument and I get the empty sub as below:&lt;/P&gt;&lt;PRE&gt;      Private Sub oAppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles oAppEvents.OnActivateDocument

        End Sub&lt;/PRE&gt;&lt;P&gt;As&amp;nbsp;you might've guessed,&amp;nbsp;any code in here will fire upon a docuement being made active, eg switching between two docs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this trigger, as with all triggers will fire twice, once before the event and once after it. this is why you're &amp;nbsp;seeing it happen twice,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To prevent this you need to tell the sub when you want it to fire, either before or after the event like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        Private Sub oAppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles oAppEvents.OnActivateDocument
            'fire after document is made active
            If BeforeOrAfter = EventTimingEnum.kAfter Then

            End If

            'fire before document is made active
            If BeforeOrAfter = EventTimingEnum.kBefore Then

            End If
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 11:52:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/6367668#M64438</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-06T11:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn event on document change</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867625#M82191</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this exactly as in your example, but for some reason it does not fire the sub.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what could be the cause?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 10:17:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867625#M82191</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-20T10:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn event on document change</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867784#M82195</link>
      <description>&lt;P&gt;You trying to adress two different events to one sub?&lt;/P&gt;&lt;PRE&gt;OnDocumentChangeEvent&lt;/PRE&gt;&lt;P&gt;it will not work this way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 11:11:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867784#M82195</guid>
      <dc:creator>marcin_otręba</dc:creator>
      <dc:date>2018-03-20T11:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn event on document change</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867818#M82197</link>
      <description>&lt;P&gt;@&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate"&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3093852" target="_self"&gt;&lt;SPAN class=""&gt;SutherNe&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt; Solution is almost comlete only one small thing that you need set oAppevents&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best way to add it in addin activate method :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;g_inventorApplication = addInSiteObject.Application&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oAppevents= g_inventorApplication.ApplicationEvents()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dont forget to declare g_inventorApplication like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public g_inventorApplication As Inventor.Application&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or use your own object for inventor...&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 11:20:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867818#M82197</guid>
      <dc:creator>marcin_otręba</dc:creator>
      <dc:date>2018-03-20T11:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: AddIn event on document change</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867891#M82198</link>
      <description>&lt;P&gt;Thanks, that did the trick!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 11:45:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/addin-event-on-document-change/m-p/7867891#M82198</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-20T11:45:56Z</dc:date>
    </item>
  </channel>
</rss>

