Adding Tabs to the Resources Taskpane

Greetings all,

I’m getting crazy here. Is it possible to add a tab to the SolidWorks Resources Taskpane into which I can put macros that I have developed?
image.png
I had a look at Toolbar+ from Cadplus, but all that does is add them to the pull down menu, about three clicks deep.

Thanks in advance!

I don’t think you can but I was sure you could create a Custom Toolbar for your own needs, can’t figure out how though.

Answering my own question.

Yes, it’s possible.

Here is a example of a vba instance: https://help.solidworks.com/2025/english/api/sldworksapi/Add_Task_Pane_View_Example_VB.htm

Most of the documentation is driven around C# instances though.

cheers

I tried to do it in C#. I’m just starting with C#. Here is the algorithm how to create AddIn in SolidWorks.

1. Create a New Project
Launch Visual Studio: Open Visual Studio.
New Project: Select Create a new project.
Project Type: Choose Class Library (.NET Framework).
Framework Selection: It is recommended to use .NET Framework 4.7.2 or 4.8, which are fully compatible with the SolidWorks API.

2. Add SolidWorks.Interop References
To interact with the SolidWorks API, you must add references to the required COM libraries:

Open Solution Explorer: Locate your project.
Add Reference: Right-click on the project → Add Reference…
Select COM Libraries: In the COM tab, locate and add the following:
SolidWorks 20XX Type Library: The main API library.
Setting: Set Embed Interop Types to False.
SolidWorks 20XX Constant Type Library: Contains API constants.
Setting: Set Embed Interop Types to False.
SolidWorks 20XX Commands Type Library: Used for working with SolidWorks commands.
Setting: Set Embed Interop Types to False.
SolidWorks 20XX Extensibility Type Library: Required for Add-In functionality.
Setting: Set Embed Interop Types to False.
Note: If SolidWorks is installed in the default location, these libraries are usually found at:
_C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS_

3. Add a WinForms User Control for the Task Pane
If you plan to include a custom user interface (such as a Task Pane):

Add a New Item: Right-click on the project in Solution Explorer → Add → New Item…
Choose Template: Select User Control (WinForms). This control will serve as your custom pane within SolidWorks.

4. Create a GUID for Your Add-In
A GUID uniquely identifies your Add-In:

Generate GUID: In Visual Studio, go to Tools → Create GUID.
Save the GUID: Generate a new GUID (for example, E7B08A32-5C91-44D7-AC8D-0C5B37EAE1A5) and keep it for later use in the registry and your code.

5. Make Your Assembly COM-Visible
To ensure COM can see your assembly, you need to mark it as COM-visible:

Edit AssemblyInfo.cs: Open the AssemblyInfo.cs file and ensure the following attribute is present:

[assembly: ComVisible(true)]

Alternative Method: Alternatively, go to Project Properties → Application → Assembly Information… and check Make assembly Com-Visible.

6. Create a Strong Name Key (SNK)
Signing the assembly ensures its integrity and prevents security warnings:

Open Project Properties: Right-click on the project in Solution Explorer → Properties.
Go to the Signing Tab: Navigate to the Signing tab.
Sign the Assembly: Check Sign the assembly.
Create New Key: Click New…, enter a key file name (e.g., MySolidWorksAddIn.snk), and if desired, uncheck Protect my key file with a password if you prefer not to use a password.

7. Register the Assembly for COM Interop
Sometimes, the built-in registration does not work correctly, so manual registration is necessary.

Registering the DLL
Open Command Prompt as Administrator: Launch CMD with administrator privileges.
Run Registration Command:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /codebase /tlb "D:\Path\To\Your\Project\bin\Debug\YourAddIn.dll"

/codebase specifies the location of your assembly.
/tlb generates the type library required for COM.
Unregistering the DLL
To remove the registration, run:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u /tlb "D:\Path\To\Your\Project\bin\Debug\YourAddIn.dll"

8. Add Registry Information for the Add-In
SolidWorks needs registry entries to recognize and load your Add-In:

Open Registry Editor: Press Win+R, type regedit, and press Enter.
Navigate: Go to:
HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\AddIns
Create a New Key: Right-click in the right pane → New → Key and name it with your Add-In’s GUID (for example, {E7B08A32-5C91-44D7-AC8D-0C5B37EAE1A5}).
Add Parameters:
String Values:
“Description” with a value like “MySolidWorksAddIn”.
“Title” with a value like “My Add-In”.
DWORD Value:
Create a DWORD (32-bit) named “LoadBehavior” and set its value to 3 (which tells SolidWorks to load the Add-In automatically on startup).

9. Remove Registry Information
If you need to delete your Add-In’s registry information, follow these steps:

Open Registry Editor: Press Win+R, type regedit, and hit Enter.
Navigate to the Add-Ins Section: Go to:
HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\AddIns
Locate Your Add-In Key: Find the key named with your Add-In’s GUID (e.g., {E7B08A32-5C91-44D7-AC8D-0C5B37EAE1A5}).
Delete the Key: Right-click the key and select Delete. Confirm the deletion when prompted.
This removal will unregister your Add-In from SolidWorks, ensuring it no longer appears in the SolidWorks Add-In manager.

Now the code directly from C#

Main Launch Class

using System;
using System.Runtime.InteropServices;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swpublished;

namespace PRP_CANDLE
{
    [ComVisible(true)]
    [Guid("66a73d52-f465-4074-ac4d-b4ea96ab")] // Unique GUID
    public class ProgramAddIn : ISwAddin
    {
        private SldWorks _swApp;
        private TaskpaneView _taskPane;
        private TaskPanelForm _myTaskPanelForm;

        public bool ConnectToSW(object ThisSW, int Cookie)
        {
            _swApp = (SldWorks)ThisSW;
            _swApp.SetAddinCallbackInfo(0, this, Cookie);
            //You will need an icon, described in Help
            _taskPane = _swApp.CreateTaskpaneView2(@"Y:\_SWsys\macro\SW_CANDLEv03\tab_icon16x18.bmp", "PRP Candle v3");
            _myTaskPanelForm = new TaskPanelForm(_swApp);
            _taskPane.DisplayWindowFromHandle(unchecked((int)_myTaskPanelForm.Handle.ToInt64()));
            return true;
        }

        public bool DisconnectFromSW()
        {
            _taskPane?.DeleteView();
            _swApp = null;
            return true;
        }
    }
}

class directly Forms panel (visual part)

using SolidWorks.Interop.sldworks;
using System.Windows.Forms;

namespace PRP_CANDLE
{
    public partial class TaskPanelForm : UserControl
    {
        private readonly ReadPrpModule _reader;
        public TaskPanelForm(SldWorks swApp)
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill; // Fills the entire TaskpaneView
            _reader = new ReadPrpModule(swApp);
           
            
            //Event handlers: Click and Resize panel
            this.Click += TaskPanelForm_Click;
            this.SizeChanged += (s, e) => AdjustTaskpaneSize();
        }
        private void AdjustTaskpaneSize()
        {
            this.textBox1.Text = this.Width.ToString();
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            ReadAndShowProperty();
        }

        private void TaskPanelForm_Load(object sender, System.EventArgs e)
        {

        }

    }
}

panel1.mp4