Launch SOLIDWORKS with Class Module VB.NET

Hello

 

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

In advance, thank you

 

Sylvain

 

 

Hello, the help section describes how to launch it, see this link

http://help.solidworks.com/2013/English/api/sldworksapiprogguide/GettingStarted/Visual_Basic_.NET_Standalone_and_Add-in_Applications.htm

Hello

 

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.

Thank you

 

Hello, indeed the previous link does not really answer the question, this tutorial may help:

https://www.youtube.com/watch?v=aoXJGKAwhbc

See also:

http://stackoverflow.com/questions/20905416/when-i-publish-a-vb-net-application-will-references-be-included

 

Hello

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.

 

Source: http://dotnet.developpez.com/faq/vbnet?page=Systeme#Comment-lancer-un-processus

 

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?

Have a nice day

1 Like

Hello

 

Thank you for these answers. The YOUTUBE video seems to be what I'm looking for.

I simply have a problem importing the dll. "Solidworks.Interop.sldworks.dll"

It appears in VB net in the solution exporter with a beware logo. If I compare the versions in vb and in windows they are not the same.

 

In fact, I want to run some SQL queries on our ERP after having for example saved a part in SOLID.

 

Thank you

 

Sylvain


problem_dll_solid_vb_net.png

What is your version of SW and Visual Studio?

I just tried it and it works but the version of the dll is 23, because I'm in SW 2015.

If you delete the reference, to add it again?

I work with Solidworks 2014 and VB Studio 2008 framework 3.5.

 

Thank you

It works like this:

A module with the code:

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?

Hello

 

A new project does not solve the problem. I think there's only one file on the disk.

I'll get in touch with Axemble to see about it.

Thanks again

 

Sylvain