3 Replies Latest reply on Jul 8, 2016 5:05 PM by Amen Allah Jlili

    how to use fileOpenNotify2

    Yannick Proulx

      Hi guys,

      I would like to update my taskPane addin when a new file is open.

      i did some search an find out that solidworks have a FileOpenNotify2 trigger but I don't know where to attach the handler.

      where should I add the handler to get the trigger when a document is open?

       

      In my DocumentEventHandler class, I tried to add the handler in the AttachEventHandlers function but it did not seem to work.

      here is a part of my doc event class :

       

      Public Class DocumentEventHandler

          Protected openModelViews As New Hashtable()

          Protected userAddin As SwAddin

          Protected iDocument As ModelDoc2

         Protected WithEvents iSwApp As SldWorks.SldWorks

       

          Overridable Function Init(ByVal sw As SldWorks.SldWorks, ByVal addin As SwAddin, ByVal model As ModelDoc2) As Boolean

          End Function

       

          Overridable Function AttachEventHandlers() As Boolean

              AddHandler iSwApp.FileOpenNotify2, AddressOf swApp_FileOpenNotify2 '<-------my taskpane update function

          End Function

       

          Overridable Function DetachEventHandlers() As Boolean

              RemoveHandler iSwApp.FileOpenNotify2, AddressOf swApp_FileOpenNotify2 '<-------my taskpane update function

          End Function

       

          Private Function swApp_FileOpenNotify2(FileName As String) As Integer Handles iSwApp.FileOpenNotify2

      'update my stuff

      end function

      end class

       

      thanks for your help once again

      Yannick