ApplicationEvent(s) to balance OnActivateDocument

ApplicationEvent(s) to balance OnActivateDocument

Maxim-CADman77
Advisor Advisor
370 Views
3 Replies
Message 1 of 4

ApplicationEvent(s) to balance OnActivateDocument

Maxim-CADman77
Advisor
Advisor

I'd like to know what ApplicationEvents can balance OnActivateDocument - I need to tight MyWidget to the active Document (if any).

 

I thought there only one - OnDeactivateDocument but I'm getting unexpected results in the scenario like this:

1. Start Inventor.
2. Start EventWatcher (one of SDK DeveloperTools) and activate "OnActivateDocument" and "OnDeactivateDocument" check boxes.
3. Open Rear Exhaust - 2 Shoe.iam (component of Engine MKII from the Legacy Samples).
4. Accept "... Would you like to update the assembly now?" request.
5. Accept "... Open Factory?" request.
6. Accept another "... Would you like to update the assembly now?" request.

I then get SIX OnActivateDocument and only FOUR OnActivateDocument events logged in EventWatcher ... which leads me to Two Widgets.

 

What I'm missing?

 

PS: I'm using Inventor 2023.3

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
371 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor

I tried to reproduce your problem with my own event viewer. (and another assembly because I could not find yours. I use the "Rear Exhaust Manifold.iam" from the 2016 samples.)  These are my results:

JelteDeJong_0-1681475873350.png

I get 2 On activate events. (1 before and 1 after activating.) Also 1 on deactivate event. That is what I expect to see. So I can't reproduce your situation. Maybe you can share your log?

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

Maxim-CADman77
Advisor
Advisor

ApplicationEvents.OnActivateDocument
    DocumentObject: Rear Exhaust - 2 Shoe.iam (kBefore)
ApplicationEvents.OnDeactivateDocument
    DocumentObject: Rear Exhaust - 2 Shoe.iam (kBefore)
ApplicationEvents.OnActivateDocument
    DocumentObject: Engine MKII.iam (kBefore)
ApplicationEvents.OnActivateDocument
    DocumentObject: Rear Exhaust - 2 Shoe.iam (kAfter)
ApplicationEvents.OnActivateDocument
    DocumentObject: Engine MKII.iam (kAfter)
ApplicationEvents.OnDeactivateDocument
    DocumentObject: Rear Exhaust - 2 Shoe.iam (kAfter)
ApplicationEvents.OnDeactivateDocument
    DocumentObject: Engine MKII.iam (kBefore)
ApplicationEvents.OnActivateDocument
    DocumentObject: Rear Exhaust - 2 Shoe.iam (kBefore)
ApplicationEvents.OnActivateDocument
    DocumentObject: Rear Exhaust - 2 Shoe.iam (kAfter)
ApplicationEvents.OnDeactivateDocument
    DocumentObject: Engine MKII.iam (kAfter)

 

PS:
The file "Rear Exhaust - 2 Shoe.iam" is a member of iAssembly "Engine MKII.iam" and it is present in Legacy Samples 2016 (located in ..Models\Assemblies\Engine MKII\Engine MKII\)

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 4

Maxim-CADman77
Advisor
Advisor

I still need some help with understanding application events (? or maybe document events ?).

My current Sub-Goal is to create AddIn that will show non-modal form with name of the active document (if any).

 

I'm showing form with:
ApplicationEvents.OnActivateDocument (After)

 

I'm closing form with:
ApplicationEvents.OnDeActivateDocument (Before)

 

Here is my current vb net project - https://github.com/CadMan77/AppEventsTestAddIn.git

(apart from showing form it also tracing some Events to simplify the debug)

 

My AddIn behaves as expected on simple scenarios (like open/close/or switch between non-iPart/iAssembly documents).


Issue occur on open the above-mentioned "Rear Exhaust - 2 Shoe.iam" (iAssembly member) with accept all update requests - then it shows the two forms (both showing "Rear Exhaust - 2 Shoe.iam").

 

Tracing log is:
Rear Exhaust - 2 Shoe.iam OnActivateDocument-BEFORE
Rear Exhaust - 2 Shoe.iam OnDeactivateDocument-BEFORE (-)
Engine MKII.iam OnActivateDocument-BEFORE
Rear Exhaust - 2 Shoe.iam OnActivateDocument-AFTER (+)
Engine MKII.iam OnActivateDocument-AFTER
Rear Exhaust - 2 Shoe.iam OnDeactivateDocument-AFTER
Engine MKII.iam OnDeactivateDocument-BEFORE
Rear Exhaust - 2 Shoe.iam OnActivateDocument-BEFORE
Rear Exhaust - 2 Shoe.iam OnActivateDocument-AFTER (+)
Engine MKII.iam OnDeactivateDocument-AFTER

 

What I'm missing and how do I achieve my Sub-Goal?

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes