Event handerls for standalone program

Event handerls for standalone program

Anonymous
Not applicable
689 Views
4 Replies
Message 1 of 5

Event handerls for standalone program

Anonymous
Not applicable

I have a standalone exe program that I am building. I am trying to capture events in Inventor. I have read all I can find about event handlers for addin's but nothing on standalone programs. Any help or direction would be appreciated.

Thanks

 

0 Likes
690 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Ok so I now am able to capture the event I was looking to in Inventor with the following code. However when the handler activates another module I run into a threading error issue (see attached picture), any direction would be appreciated:

 

Imports Inventor.InteractionEventsEnum

Module Module3

Private WithEvents m_AppEvents As Inventor.ApplicationEvents

Private m_inventorApplication As Inventor.Application

Public Sub UsewithEvents()

m_inventorApplication = GetObject(, "Inventor.Application")

m_AppEvents = m_inventorApplication.ApplicationEvents

End Sub

Private Sub m_AppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_AppEvents.OnActivateDocument

Module4.BOM()

End Sub

 

 

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

When working with a seperate application, you are trying to control Inventor from an other thread and that leads to threading errors. From my point of view, what you want to do is to convert your application into a plugin. That way, it would be executed within Inventor and would eliminate threading errors.

 

Any special reasons why you want a seperate application?

 

If possible, it would be even safer to create a macro or a iLogic and have it triggered by the iLogic Event Hangler. But that solution would be very slow to execute if you are planning of doing a lot of processing...

 

Hope it helps.

0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks for the reply pberube. Your probably correct and I should have gone with a plugin. But I finally just used the code below to get it working. Probably not the best approch but we shall see how it goes. Just working on an application that will handle many different functions. This particular part is for iProps. Attached zip file contains a video of what I was trying to accomplish.

 

System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False

0 Likes
Message 5 of 5

adam.nagy
Autodesk Support
Autodesk Support

It sounds like the issue is along the lines of not using STA, or not marshaling execution to the main thread:

- http://adndevblog.typepad.com/autocad/2012/09/reach-functions-of-a-net-plug-in-from-another-applicat...

- http://adndevblog.typepad.com/manufacturing/2014/09/apprentice-in-side-thread.html 

 

If you could provide a minimal set of projects to reproduce the issue that could be helpful.

 

Concernig events handling this might be useful to know too:

http://modthemachine.typepad.com/my_weblog/2012/07/set-embed-interop-types-to-false-to-avoid-problem... 



Adam Nagy
Autodesk Platform Services
0 Likes