solidworksvsta

Solidworks 2020 VSTA User Form


I have created a empty SolidWorks macro, using VSTA 3.0 C# projet.

I tried that very simple example. It "works" but the process continue. I want to show a form. And wait for user to hit button to do tasks or quit.

    public void Main()
    {
        var frm = new Form1();
        frm.Show();

        return;
    }

    // The SldWorks swApp variable is pre-assigned for you.
    public SldWorks swApp;

Solution

  • One way to do this is simply to add Application.Run() :

    public void Main()
    {
        var frm = new Form1();
        frm.Show();
        Application.Run(frm);
    
        return;
    }
    
    // The SldWorks swApp variable is pre-assigned for you.
    public SldWorks swApp;