DocumentCreatedEventArgs and DocumentOpenedEventArgs Document is null

DocumentCreatedEventArgs and DocumentOpenedEventArgs Document is null

harmvandenbrand
Contributor Contributor
280 Views
1 Reply
Message 1 of 2

DocumentCreatedEventArgs and DocumentOpenedEventArgs Document is null

harmvandenbrand
Contributor
Contributor

Hi all,

 

I maintain a Revit addin that we ship for Revit versions 2019 through 2022. Recently we've been receiving some strange error reports through our automatic error-reporting back-end. The "Document" parameter of DocumentCreatedEventArgs and DocumentOpenedEventArgs, which trigger when the user creates a new or opens an existing Revit document, is null. I haven't been able to replicate the exception as of yet, so gathering more information is difficult.

Are there known situations in which either the DocumentOpened or DocumentCreated events, or both, have a null Document?

0 Likes
Accepted solutions (1)
281 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni
Accepted solution

Please read the documentation:

 

https://www.revitapidocs.com/2022/7e5bc7a1-0475-b2ec-0aec-c410015737fe.htm

 

The remarks explain:

 

> This event ... is raised even when document opening failed or was cancelled (during DocumentOpening event).

 

That sounds like a pretty probable cause to me.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes