4 Replies Latest reply on Jul 6, 2017 5:52 PM by Amen Allah Jlili

    Addin FileSaveNotify EventHandler not firing for SolidWorks 2017

    Rey Bustamante

      I'm making an Addin that executes when you save a drawing file. I'm using the FileSaveNotify event handler. The event handler fires when using SW 2016 or older, but not for 2017.

      FileOpenNotify still fires, but the ActiveDoc event handlers do not. The Addin does register with SolidWorks.

       

       public bool ConnectToSW(object thisSw, int cookie)
              {
                  SwApp = (SldWorks.SldWorks)thisSw;
                  _addinId = cookie;
                  SwApp.SetAddinCallbackInfo(0, this, _addinId);
                  AttachEventHandlers();
                  CommandManager = SwApp.GetCommandManager(cookie);
                  AddCommandManager();
                  return true;
              }
      
      
              public void AttachEventHandlers()
              {
                  SwApp.FileOpenNotify += SwApp_FileOpenNotify;
              }
      
      
              private int SwApp_FileOpenNotify(string FileName){
                  //((DrawingDoc)SwApp.ActiveDoc).FileSaveNotify -= SwApp_FileSaveNotify;
                  ((DrawingDoc)SwApp.ActiveDoc).FileSaveNotify += SwAddin_FileSaveNotify;
                  MessageBox.Show("test hello test1");
                  return 0;            
              }
      
      
              private int SwAddin_FileSaveNotify(string FileName)
              {
                  MessageBox.Show("Save ADD IN TEST");
      
      
                  return 0;
              }
      
      
      
      
              public bool DisconnectFromSW()
              {
                  RemoveCommandManager();
                  SwApp = null;
                  GC.Collect();
                  return true;
              }
      

       

      Is there something I'm doing wrong in my code? Do I need to change something for SW2017?