- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using Inventor api with C#. I want create a listener for Inventor 2016. For example Let alert (message.box) when opened save as dailog or etc.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sounds cool and what is the question here?
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hmm does not seem like you said that..
I want to..
How to..
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?
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'd love to see that Jef
Some worthwhile ideas
Copy Design should rename ilogic Rules too!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Inventor ships with an event watcher tool. Install the developer tools and look for EventWatcher.exe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Change the target framework..
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
İrfan Şahin dostum;
Did you translate Mr. Jef's VB codes to C#?
I just need handling of OnDocumentActive, but not as addin; I'm trying to make an executable application. May you help me?
Thanks in advance to everybody.
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()
{
// I'm Getting error: No overload for .. matches delegate..
OnActivateDocumentDelegate = new ApplicationEventsSink_OnActivateDocumentEventHandler(I_Need_This);
ApplicationEvents.OnActivateDocument += OnActivateDocumentDelegate;
}
public void Deactivate()
{
ApplicationEvents.OnActivateDocument -= OnActivateDocumentDelegate;
OnActivateDocumentDelegate = null;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In VB using ByRef works, but in C# it does not!
I found the solution: out in, ref out ![]()
For the ones like me in yesterday..
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
{
//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
}
}Tags:
"Inventor Application Events"
"Handling Inventor Events Using C#"
"Inventor OnActvateDocument"
"ApplicationEventsSink_OnActivateDocumentEventHandler"
