I recently worked on a VBA class module that I launch when starting Solidworks with the command "C:\Program Files\SolidWorks Corp\SolidWorks\SLDWORKS.exe" /m "here the path of the macro.swp".
I would now like to switch to a .NET-coded class module but can't start SOLIDWORKS with this class. Do you have an example to give me?
I'm using the following code:
"C:\Program Files\SolidWorks Corp\SolidWorks\SLDWORKS.exe" /m "C:\Users\ClassLibrary1.dll" to launch the DLL
Thank you for your answer. In fact I had already entered this piece of code to access from the class module the functions of SOLID (open doc, save ...) but I can't launch SOLIDWORKS with the class module.
I'll look more on the SOLID website as soon as I'm in the office.
Try this code: by adapting it with SLDWORKS.exe and argument the path of your part
Instance of the Process class Dim proc As New System.Diagnostics.Process() ' Name of the executable to be launched Proc. StartInfo.FileName = "iexplore.exe" ' Arguments to pass to the executable to launch Proc. StartInfo.Arguments="http://www.developpez.com" ' Starting the process Proc. Start() "We free up the resources we need more. Proc. Close() 'Attention Close does not end the process.
I think it would be useful to test if the process is already started. To do this, see this track: http://dotnet.developpez.com/faq/vbnet?page=Systeme#Comment-lister-les-processus-en-cours-d-execution
Can you tell us a little more about your VB.net project?
Imports System.Diagnostics Module Module_principal Function Verification_processus_SW() As Boolean Dim Processus_SW as System.Diagnostics.Process() = Process.GetProcessesByName("SLDWORKS") If Processus_SW. Count = Nothing Then Return False Else Return True End If End Function
Sub Lancement_SW() Dim proc As New Process() Proc. StartInfo.FileName = "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\SLDWORKS.exe" ' Arguments to pass to the executable to launch Proc. StartInfo.Arguments = "Chemin_de_ton_fichier.sldprt" ' Starting the process Proc. Start() "We free up the resources we need more. 'proc. Close() 'Attention Close does not end the process. End Sub End Module
A button or other to activate with the code:
Select Case Verification_processus_SW() Case False Lancement_SW() Case True 'Code to add in case SW is already running End Select End Sub
And by trying a new project to include the dll, does it work? The YouTube tutorial is rather simple, there is only one file with this name on the hard drive?