Application.ActiveDocumentChanging & Application.ActiveDocumentChanged events not triggered

Application.ActiveDocumentChanging & Application.ActiveDocumentChanged events not triggered

alexisDVJML
Collaborator Collaborator
795 Views
3 Replies
Message 1 of 4

Application.ActiveDocumentChanging & Application.ActiveDocumentChanged events not triggered

alexisDVJML
Collaborator
Collaborator

I was expecting Application.ActiveDocumentChanging & Application.ActiveDocumentChanged events to be triggered when opening a document or choosing New, so our plugin can clear its cache etc.

Seems this is not happening.

 

Only event I seem to get is Document.FileNameChanged.
Which is also called when saving under a new name, which make sense for a save as BUT does not make any sense when changing document !!!

So wondering how to know when a document is "closed"/ another one become the current one?
This is key to almost any plug-in so I'm sure I am missing something 😉

Thanks in advance.

 

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Accepted solutions (1)
796 Views
3 Replies
Replies (3)
Message 2 of 4

tetsuya_miwa
Advocate
Advocate
Accepted solution
Message 3 of 4

alexisDVJML
Collaborator
Collaborator

Thanks @tetsuya_miwa !

 

Yes, exactly that.

 

I would say it is a bug even if Navisworks is a SDI app.

MainDocumentChanging and MainDocumentChanged not raised in a SDI app makes total sense but ActiveDocumentChanging/Changed should be raised!

 

The hack of using FileNameChanged is just a dirty hack, the same I used until now actually.
And it still does not solve lots of dangerous issues: Models, SavedViewPoints etc being reset, events being raised on those etc. while everything is in an unknown state. I had a gazillion of hangs just because of this, and the source code to handle all these edge cases is a real soup 😬

 

@Autodesk, please settle this in future releases. 

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Message 4 of 4

tetsuya_miwa
Advocate
Advocate

Did you read this Xiaodong's blog?
https://adndevblog.typepad.com/aec/2012/06/eventwatcherplugin-cannot-work-after-navisworks-launches....

He recomended to use ActiveDocument.Models.CollectionChanged event instead.