I'm having a general problem with the ApplicationEvents. They wont fire as they should...but sometimes they do!!
It's sort of like a 50/50 chance that they are working
Currenty I'm hooking up the OnQuit, OnOpenDocument and the OnSaveDocument events using the following code:
_application.ApplicationEvents.OnQuit += ApplicationEvents_OnQuit; void ApplicationEvents_OnQuit(EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode) { switch (BeforeOrAfter) { case EventTimingEnum.kBefore: SaveSettingsToXml(_addinSettingsFilename); HandlingCode = HandlingCodeEnum.kEventNotHandled; break; default: HandlingCode = HandlingCodeEnum.kEventNotHandled; break; } }
This model is applicable to all the events i mentioned, and is pretty straight forward. Tried running in Debug/Release which rules out any VisualStudio debugging problems, and right now I'm sort of out of ideas?! Anyone else having similar problems?
Previous versions of this addin seems to be working ok using VB.Net - could there some sort of problem related to c#?
I ran into this same issue. You need to use an event sink. So it would be
_application.ApplicationEvents.OnQuit = new ApplicationEventsSink_OnQuitEventHandler(ApplicationEvents_OnQuit);
For some reason don't see a mention of them in the more recent apis but it's in the 2011 version. I know if I don't use them with C# event's don't seem to work correctly.
Still having problems with this...any other idea? The OnCloseDocument-event seems to trigger now every time after using the ApplicationEventsSink. But this won't work!
_application.ApplicationEvents.OnQuit += new ApplicationEventsSink_OnQuitEventHandler(ApplicationEventsSink_OnQuitEventHandler);
private void ApplicationEventsSink_OnQuitEventHandler(EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode) { switch (BeforeOrAfter) { case EventTimingEnum.kBefore: SaveSettingsToXml(_addinSettingsFilename); HandlingCode = HandlingCodeEnum.kEventNotHandled; break; default: HandlingCode = HandlingCodeEnum.kEventNotHandled; break; } }
The following post may be useful, in particular keeping the ApplicationEvents object referenced.
http://forums.autodesk.com/t5/inventor-customization/events-in-the-api/m-p/3755999#M41929
Regards,
cadull
Can't find what you're looking for? Ask the community or share your knowledge.