Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
366 Views, 1 Reply

OnNewDocument Firing Multiple Times

 

I am trying to capture the application event OnNew Document to provide some actions after the new file has been created.

What I am experiencing is that when capturing the event and then filtering to repond the event is fired upto 3 times with BeforeOrAfter = After. This is occurring when the

 

My routine takes the form (not actual Vb code)

 

Public Sub OnNewDocument( DocumentObject As Document, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, HandlingCode As HandlingCodeEnum )

 

if BeforeOrAfter <> kAfter then return

if DocumentObject.document type <> kInventorDrawingDocument then return

 

Some code to display a dialogue and alter number of sheets in drawing.

 

End

 

 

What seeems to be occuring is the dialogue, display works, creates the extra sheets, but then is displayed up to 2 times more. This is intermittent and sometimes diplays once, twice or thrice. I beleive the event is triggering this many times as if I strip all my code out and simply show a message box on the event the same happens.

 

Any Clues? I presume Inventor may be making new docs in the background perhaps?

 

Is there any easy way to filter perhaps on Context data?

 

Regards Ian