solidworks add-in 插件UI Methods函数

"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()"
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 设计模式分类 总体来说设计模式分为三大类:创建型模式,共五种:工厂方法模式、抽象工厂模式、单例模式、建造者模式、原...
    lifeline丿毅阅读 1,259评论 0 2
  • 在多数情况下,初始化一个对象的最终步骤是去调用这个对象的构造方法。构造方法负责对象的初始化工作,为实例变量赋予合适...
    我是陈君本阅读 776评论 0 3
  • 50道经典Java编程练习题,将数学思维运用到编程中来。抱歉哈找不到文章的原贴了,有冒犯的麻烦知会声哈~ 1.指数...
    OSET我要编程阅读 7,178评论 0 9
  • WindowManager.LayoutParams 是 WindowManager 接口的嵌套类;继承于 Vie...
    Kevin_Zhou阅读 1,256评论 0 4
  • 50道JAVA基础编程练习题 【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子...
    微尘_8957阅读 2,210评论 0 2