Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OnNewDocument Firing Multiple Times

1 REPLY 1
Reply
Message 1 of 2
woodstylee2
279 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

1 REPLY 1
Message 2 of 2

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



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report