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
Hi Ian,
this is a piece of VB.net code of my addins, may this help you.
' variables declarations
Private WithEvents m_appEvents As Inventor.ApplicationEvents
' some code
Private Sub m_appEvents_OnNewDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, _ ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_appEvents.OnNewDocument Try If BeforeOrAfter = EventTimingEnum.kBefore Then ' some code End If Catch ex As Exception End Try HandlingCode = HandlingCodeEnum.kEventHandled End Sub
Bregs
Rossano Praderi