美文网首页
solidworks add-in 插件UI Methods函数

solidworks add-in 插件UI Methods函数

作者: dududuwei | 来源:发表于2018-04-29 09:53 被阅读0次

"Public Sub AddCommandMgr()

    Dim cmdGroup As ICommandGroup 
    Dim cmdGroup1 As ICommandGroup

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

    Dim thisAssembly As Assembly

    Dim cmdIndex0 As Integer, cmdIndex1 As Integer, cmdIndex2 As Integer, cmdIndex3 As Integer, cmdIndex4 As Integer

    Dim Title As String = "MY-addin"
    Dim ToolTip As String = "More"


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

    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



    cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("SwVBAddin1.ToolbarLarge.bmp", thisAssembly)
    cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("SwVBAddin1.ToolbarSmall.bmp", thisAssembly)
    cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("SwVBAddin1.MainIconLarge.bmp", thisAssembly)
    cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("SwVBAddin1.MainIconSmall.bmp", thisAssembly)

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

    cmdIndex0 = cmdGroup.AddCommandItem2("圆柱拉伸", -1, "圆柱拉伸", "圆柱拉伸", 0, "yuanzhu", "", mainItemID1, menuToolbarOption)
    cmdIndex1 = cmdGroup.AddCommandItem2("边界曲面", -1, "边界曲面", "边界曲面", 1, "qumian", "", mainItemID2, menuToolbarOption)
    cmdIndex2 = cmdGroup.AddCommandItem2("油箱", -1, "油箱", "油箱", 2, "qumian", "", mainItemID2, menuToolbarOption)
    ‘依次为 名字,位置(-1代表添加到后面),鼠标掠过提示信息

    cmdGroup.HasToolbar = True
    cmdGroup.HasMenu = True
    cmdGroup.Activate()"

相关文章

网友评论

      本文标题:solidworks add-in 插件UI Methods函数

      本文链接:https://www.haomeiwen.com/subject/midolftx.html