<?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: Inventor C# Listener in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430793#M65403</link>
    <description>&lt;P&gt;I said. How can I listen Inventor API with C# ? Can you give me sample codes or tricks.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jul 2016 07:50:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-12T07:50:56Z</dc:date>
    <item>
      <title>Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430266#M65395</link>
      <description>&lt;P&gt;I am using Inventor api with C#. I want create a listener for Inventor 2016. For example &lt;SPAN class="short_text"&gt;&lt;SPAN&gt;Let&lt;/SPAN&gt; &lt;SPAN class=""&gt;alert (message.box) when&lt;/SPAN&gt; &lt;SPAN class=""&gt;opened save as dailog or etc&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 22:27:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430266#M65395</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-11T22:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430677#M65398</link>
      <description>&lt;P&gt;Sounds cool and what is the question here?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:20:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430677#M65398</guid>
      <dc:creator>Jef_E</dc:creator>
      <dc:date>2016-07-12T06:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430793#M65403</link>
      <description>&lt;P&gt;I said. How can I listen Inventor API with C# ? Can you give me sample codes or tricks.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 07:50:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430793#M65403</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-12T07:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430809#M65404</link>
      <description>&lt;P&gt;Hmm does not seem like you said that..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to..&lt;/P&gt;
&lt;P&gt;How to..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what version of Inventor are you using? there are enough sample in the API to do this I think. I don't have C# code to show for.. only VB.NET if you can translate it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 08:05:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430809#M65404</guid>
      <dc:creator>Jef_E</dc:creator>
      <dc:date>2016-07-12T08:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430879#M65405</link>
      <description>&lt;P&gt;I'd love to see that Jef&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 09:17:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6430879#M65405</guid>
      <dc:creator>tolgay.hickiran</dc:creator>
      <dc:date>2016-07-12T09:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6431494#M65418</link>
      <description>&lt;P&gt;Inventor ships with an event watcher tool. Install the developer tools and look for EventWatcher.exe&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 14:39:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6431494#M65418</guid>
      <dc:creator>nmunro</dc:creator>
      <dc:date>2016-07-12T14:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6432010#M65427</link>
      <description>&lt;P&gt;I am using Inventor 2016 Premium. Yes Jef_E, I can translate vb to c#. If you give me any sample I be to happy.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 17:50:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6432010#M65427</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-12T17:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6433112#M65445</link>
      <description>&lt;P&gt;As stated by &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/35568"&gt;@nmunro﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I attached a zip file with the event watcher from Autodesk written in vb.net&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 07:54:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6433112#M65445</guid>
      <dc:creator>Jef_E</dc:creator>
      <dc:date>2016-07-13T07:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6434655#M65459</link>
      <description>&lt;P&gt;Can you compile your sended project ? I see that in developer tools but was giving compile error as your sended.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 19:25:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6434655#M65459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-13T19:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6435510#M65467</link>
      <description>&lt;P&gt;Change the target framework..&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 08:42:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6435510#M65467</guid>
      <dc:creator>Jef_E</dc:creator>
      <dc:date>2016-07-14T08:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6711842#M68212</link>
      <description>&lt;P&gt;İrfan Şahin dostum;&lt;/P&gt;&lt;P&gt;Did you translate Mr. Jef's VB codes to C#?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just need handling of OnDocumentActive, but not as addin; I'm trying to make an executable application. May you help me?&lt;/P&gt;&lt;P&gt;Thanks in advance to everybody.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using Inventor;

namespace WpfInventor45
{
    public interface IApplicationEventsLib
    {
        ApplicationEvents ApplicationEvents { get; }
        
        ApplicationEventsSink_OnActivateDocumentEventHandler OnActivateDocumentDelegate
        {
            get;
            set;
        }
        
        void Deactivate();

        void I_Need_This(Inventor._Document DocumentObject, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode);
    }

    public class ApplicationEventsLib : IApplicationEventsLib
    {
        private readonly Application inventorApp;

        public ApplicationEventsLib(Application inventorApp)
        {
            this.inventorApp = inventorApp;
            ApplicationEvents = this.inventorApp.ApplicationEvents;
            Activate();
        }

        public ApplicationEventsSink_OnActivateDocumentEventHandler OnActivateDocumentDelegate
        {
            get; set;
        }
        
        public ApplicationEvents ApplicationEvents { get; private set; }

        public void I_Need_This(Inventor._Document DocumentObject, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
        {
            if ((BeforeOrAfter == Inventor.EventTimingEnum.kAfter))
                Console.WriteLine("Code here!!");
        }

        private void Activate()
        {&lt;BR /&gt;            // I'm Getting error: No overload for .. matches delegate..  
            OnActivateDocumentDelegate = new ApplicationEventsSink_OnActivateDocumentEventHandler(I_Need_This);
&lt;BR /&gt;            ApplicationEvents.OnActivateDocument += OnActivateDocumentDelegate;            
        }

        public void Deactivate()
        {
            ApplicationEvents.OnActivateDocument -= OnActivateDocumentDelegate;
            OnActivateDocumentDelegate = null;
        }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Nov 2016 21:32:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6711842#M68212</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-27T21:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor C# Listener</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6714201#M68246</link>
      <description>&lt;P&gt;In VB using ByRef works, but in C# it does not!&lt;/P&gt;&lt;P&gt;I found the solution: out in, ref out&amp;nbsp;&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the ones like me in yesterday..&lt;/P&gt;&lt;PRE&gt;using Inventor; //autodesk.inventor.interop

private Inventor.Application m_App = null;
private Inventor.ApplicationEvents m_ApplicationEvents = null;

private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {&lt;BR /&gt;               //Inventor.Application application = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
                m_App = InitializeInventor(true, true);

                if (m_App != null)
                {                    
                    m_ApplicationEvents = m_App.ApplicationEvents;                   
                    m_App.ApplicationEvents.OnActivateDocument +=  ApplicationEvents_OnActivateDocument;
                    m_App.ApplicationEvents.OnQuit += ApplicationEvents_OnQuit;
                }
                else                
                    System.Environment.Exit(0);                
            }
            catch
            { }
        }

        void ApplicationEvents_OnQuit(EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
        {
            switch (BeforeOrAfter)
            {
                case EventTimingEnum.kBefore:
                    //Do Something;
                    HandlingCode = HandlingCodeEnum.kEventNotHandled;
                    break;
                default:
                    HandlingCode = HandlingCodeEnum.kEventNotHandled;
                    break;
            }
        }

//Use out instead of ref
        void ApplicationEvents_OnActivateDocument(_Document DocumentObject, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
        {
            HandlingCode = HandlingCodeEnum.kEventNotHandled; //This line is Important
            if ((BeforeOrAfter == Inventor.EventTimingEnum.kBefore))
            {
                //Do Something
            }
        }&lt;/PRE&gt;&lt;P&gt;Tags:&lt;/P&gt;&lt;P&gt;"Inventor Application Events"&lt;/P&gt;&lt;P&gt;"Handling Inventor Events Using C#"&lt;/P&gt;&lt;P&gt;"Inventor OnActvateDocument"&lt;/P&gt;&lt;P&gt;"ApplicationEventsSink_OnActivateDocumentEventHandler"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 21:51:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/inventor-c-listener/m-p/6714201#M68246</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-28T21:51:36Z</dc:date>
    </item>
  </channel>
</rss>

