-
Re: .net code opens a new instance of SolidWorks
Ivana Kolin Jun 4, 2015 5:15 AM (in response to Dennis Hvam)Hello Dennis,
try this:
swApp = GetObject(, "SldWorks.Application")
-
Re: .net code opens a new instance of SolidWorks
Dennis Hvam Jun 4, 2015 5:21 AM (in response to Ivana Kolin)-
Re: .net code opens a new instance of SolidWorks
Ivana Kolin Jun 4, 2015 5:57 AM (in response to Dennis Hvam)do you have reference to SolidWorks.Interop.sldworks.dll
from this map : <SolidWorks_install_dir>\api\redist or <SolidWorks_install_dir>\api\redist\CLR2 if you use Microsoft .NET Framework Version 2.0.?
-
Re: .net code opens a new instance of SolidWorks
Dennis Hvam Jun 4, 2015 6:10 AM (in response to Ivana Kolin)Hello Ivana,
I do:
But I might have solved it, or I believe it works now:
swApp = GetObject("", "SldWorks.Application.22")
22 is added for solidworks 2014, it seems to work and my rebuild is now successfull, or the codes tell me that it is. No extra instance of solidworks is started as well.
So I need to change 22 is its running with other versions of solidworks I guess.
-
Re: .net code opens a new instance of SolidWorks
Adam Hoffman Jun 4, 2015 12:18 PM (in response to Dennis Hvam)Try this:
Try
swApp = System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application")
Catch SolidWorksConnectError As Exception
Debug.WriteLine(SolidWorksConnectError)
End TryThis way you won't have to have your code version number specific.
-
-
-
-