Search code examples
vb.netsolidworkscreateobject

VB.NET application. Create a Solidworks session using CreateObject and .UserControl = True but the session is not 100% usable for the user


I tried many things and searched a lot on the web and on this site, but I could not find a solution. I have a problems which is:

I'm making an application in VB.NET that connects to Solidworks.

Case 1: Solidworks is running.

  • swApp.CreateObject ("SldWorks.Application") / swApp.UserControl = True / swApp.Visible = True

  • Double click on solidworks file (part, assembly or drawing) = solidworks opens the document in the current session.

Case 2: Solidworks is not running.

  • swApp.CreateObject ("SldWorks.Application") / swApp.UserControl = True / swApp.Visible = True
  • Double click on solidworks file (part, assembly or drawing) = solidworks does NOT open the document.

Case 2 produces a solidworks session useful for my application, but not for the user. I want to make case 2 behave like the case 1. Any suggestions?

From already thank you very much!


Solution

  • Here is a solution that worked for me: Looking at the Windows Task Manager I realized that the problem can be overcome by opening a solidworks file (ex: .sldprt)... not Soliworks.exe directly: Process.Start("path of some solidworks file") and then wait for the process "swShellFileLauncher.exe" ceases before using swApp.CreateObject("SldWorks.Application")