I am building a small addin for Inventor, and I have a problem when attatching a delegate to the Application.ApplicationEvents.OnSaveDocument-event.
Setting a breakpoint on this line of code when debugging:
Application.ApplicationEvents.OnSaveDocument += new ApplicationEventsSink_OnSaveDocumentEventHandler(OnSaveDocument_Delegate);
and continuing the execution after the breakpoint was hit, will result in a working addin, i.e the OnSaveDocumentEvent fires as it should.
BUT. When not having the breakpoint enabled the event doesn't work...it's almost as if things moves too fast for it to register?!
I've tried executing the adding of the delegate on a separate thread, but that's not working.
Anyone got an idea what I can do about this?.
Use BeforeOrAfter
Input indicating if the notification is being sent before the document is saved (kBefore), after a change is made (kAfter), or when a change has been aborted (kAbort).
I am using BeforeOrAfter, executing my code "kAfter" a successful save, or "kAbort" when no change is made to the document:
switch (BeforeOrAfter) { case EventTimingEnum.kAfter: SetDocumentRotation(); HandlingCode = HandlingCodeEnum.kEventHandled; break; case EventTimingEnum.kAbort: SetDocumentRotation(); HandlingCode = HandlingCodeEnum.kEventHandled; break; default: HandlingCode = HandlingCodeEnum.kEventNotHandled; break; }
The event doesn't trigger at all when not using that stupid breakpoint...
It seems that the reason it's not working is not my code =). Got a pluginloader working to load about 10 plugins and I suspect somethings wrong in that one!