1 Reply Latest reply on Aug 22, 2017 12:47 AM by Manikandan Babu

    Getting current solidworks window, not a new window

    Lindsen Cruz

      I am having problems getting the current solidworks window when multiple versions of SolidWorks is open. I want to get an instance of swApp from the currently active 2017 SolidWorks window.

      SldWorks swApp = (SldWorks)Activator.CreateInstance(Type.GetTypeFromProgID("SolidWorks.Application"));
      

      or specifically I want 2017 SolidWorks

      SldWorks swApp = (SldWorks)Activator.CreateInstance(Type.GetTypeFromProgID("SolidWorks.Application.25"));
      

       

      This works when only the 2017 version is opened. However, if 2012 was opened first, and the 2017 opened second, the above code creates a new window of SolidWorks 2017 instead of grabbing the current one.

       

      Is it possible to be able to select which version and stop from making new windows?