2 Replies Latest reply on Jul 16, 2014 11:30 PM by Daniel Andersson

    Customize Menu Bar flyout with Add-in [VB]

    Daniel Andersson



      I have tried and tried and can not figure out how to do this... I'm able to create regular menus as image below shows (Ready for TC) etc.

      But when it comes to modify the flyout on the menu bar I get stuck. I have googled and search this forum with no luck. I hope that someone here can guide me...


      What I want to do is to add a button to the area marked with the read box. I'm using visual studio VB express 2010. Running SolidWorks 2012 sp5.

      I have created the add-in with the templates provided from the SDK that came with SolidWorks 2012 sp5.


      I belive that this would be possible using the command manager... but I do not figure our how. Cross my fingers to get help here


      As reference here is the current code in the AddCommandManager() for the add-in. It is almost out of the box from the SW add-in templates.


          Public Sub AddCommandMgr()

              Dim cmdGroup As ICommandGroup

              If iBmp Is Nothing Then
                  iBmp = New BitmapHandler()
              End If

              Dim thisAssembly As Assembly

              Dim cmdIndex0 As Integer, cmdIndex1 As Integer
              Dim Title As String = "Ready for TC"
              Dim ToolTip As String = "Ready for TC"

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

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

              Dim cmdGroupErr As Integer = 0
              Dim ignorePrevious As Boolean = False

              Dim registryIDs As Object = Nothing
              Dim getDataResult As Boolean = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, registryIDs)

              Dim knownIDs As Integer() = New Integer(1) {mainItemID1, mainItemID2}

              If getDataResult Then
                  If Not CompareIDs(registryIDs, knownIDs) Then 'if the IDs don't match, reset the commandGroup
                      ignorePrevious = True
                  End If
              End If

              cmdGroup = iCmdMgr.CreateCommandGroup2(mainCmdGroupID, Title, ToolTip, "", -1, ignorePrevious, cmdGroupErr)
              If cmdGroup Is Nothing Or thisAssembly Is Nothing Then
                  Throw New NullReferenceException()
              End If

              Dim menuToolbarOption As Integer = swCommandItemType_e.swMenuItem Or swCommandItemType_e.swToolbarItem

              cmdIndex0 = cmdGroup.AddCommandItem2("Ready for TC", -1, "Get SW files ready for TC", "Adds, updates attributes and equations for Teamcenter", 0, "MsgTest0", "", mainItemID1, menuToolbarOption)

              cmdGroup.HasMenu = True

              thisAssembly = Nothing
          End Sub