Hide Table of Contents

Create CommandManager Tab Example (VB.NET)

This example shows how to create a CommandManager command tab.

NOTES:

  • This example is only a code snippet. The complete project is available in the SOLIDWORKS API SDK.

  • Your add-in must check to see if the tab already exists. If the tab already exists, then you must use that tab instead of creating a new tab. If your add-in does not check for an existing tab, then SOLIDWORKS will create a new tab each time it starts up.



...

        Dim cmdGroup As ICommandGroup

        Dim iBmp As New BitmapHandler

        Dim thisAssembly As Assembly

 

        Dim cmdIndex0 As Integer, cmdIndex1 As Integer

        Dim Title As String = "VB Addin"

        Dim ToolTip As String = "VB Addin"

 

 

        Dim docTypes() As Integer = {swDocumentTypes_e.swDocASSEMBLY, _

                                       swDocumentTypes_e.swDocDRAWING, _

                                       swDocumentTypes_e.swDocPART}

 

        thisAssembly = System.Reflection.Assembly.GetAssembly(Me.GetType())

 

        cmdGroup = iCmdMgr.CreateCommandGroup(1, Title, ToolTip, "", -1)

        cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("SwVBAddin3.ToolbarLarge.bmp", thisAssembly)

        cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("SwVBAddin3.ToolbarSmall.bmp", thisAssembly)

        cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("SwVBAddin3.MainIconLarge.bmp", thisAssembly)

        cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("SwVBAddin3.MainIconSmall.bmp", thisAssembly)

 

        cmdIndex0 = cmdGroup.AddCommandItem("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", 0)

        cmdIndex1 = cmdGroup.AddCommandItem("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "PMPEnable", 2)

 

        cmdGroup.HasToolbar = True

        cmdGroup.HasMenu = True

        cmdGroup.Activate()

 

        For Each docType As Integer In docTypes

            Dim cmdTabs() As Object = iCmdMgr.CommandTabs(docType)

            Dim cmdTab As ICommandTab

 

            Dim tabExists As Boolean = False

 

            For i As Integer = 0 To iCmdMgr.GetCommandTabCount(docType) - 1

                cmdTab = cmdTabs(i)

                If cmdTab.TabName = Title Then

                    tabExists = True

                    Exit For

                End If

            Next

 

            If Not tabExists Then

                cmdTab = iCmdMgr.CreateCommandTab(-1, Title, docType)

 

 

                cmdTab.AddCommand(cmdGroup.CommandID(cmdIndex0))

                cmdTab.SetTextDisplay(cmdGroup.CommandID(cmdIndex0), swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal)

 

                cmdTab.AddCommand(cmdGroup.CommandID(cmdIndex1))

                cmdTab.SetTextDisplay(cmdGroup.CommandID(cmdIndex1), swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal)

 

                cmdTab.AddCommand(cmdGroup.ToolbarId)

                cmdTab.SetTextDisplay(cmdGroup.ToolbarId, swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow)

 

                cmdTab.AddSeparator(cmdGroup.ToolbarId)

            End If

        Next

 

        thisAssembly = Nothing

        iBmp.Dispose()

    End Sub

...

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create CommandManager Tab Example (VB.NET)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2025 SP2

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.