×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

@

Thing you should read before asking a question.

Use easily readable formats

Post your question in a format that is easy to read. stating "The problem is..."

Be precise

When asking for help because something does not work, be precise in describing what is happening. This includes a detailed description of what you did, and a full copy of the output.

Other information that you should consider including

* which operating system you are using;

* which Software version you are using;

* the exact output/error message that is produced.

Report

Replies, comments and Discussions:

  • 工作学习 / 专业知识杂谈 / any body can help me out this thing, it is try to add a menu to solidworks. thanks
    本文发表在 rolia.net 枫下论坛VERSION 1.0 CLASS
    BEGIN
    MultiUse = -1 'True
    Persistable = 0 'NotPersistable
    DataBindingBehavior = 0 'vbNone
    DataSourceBehavior = 0 'vbNone
    MTSTransactionMode = 0 'NotAnMTSObject
    END
    Attribute VB_Name = "Application"
    Attribute VB_GlobalNameSpace = True
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = False
    Attribute VB_Exposed = True
    'Make sure that a reference to the swpublished.tlb type library exists

    'Tell VB that you are going to provide functionality for the SwAddin interface
    Implements SWPublished.SwAddin

    Dim iSldWorks As SldWorks.SldWorks
    Dim iCookie As Long

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Implementation methods of the SwAddin interface
    Private Function SwAddin_ConnectToSW(ByVal ThisSW As Object, ByVal Cookie As Long) As Boolean
    ' need to add "Microsoft Scripting Runtime"
    Dim fso As New Scripting.FileSystemObject

    Dim pictNone As Picture
    Dim pictPart As Picture
    Dim pictAssy As Picture
    Dim pictDraw As Picture

    Dim fileNone As String
    Dim filePart As String
    Dim fileAssy As String
    Dim fileDraw As String

    Dim bRet As Boolean

    ' store reference to SW session
    Set iSldWorks = ThisSW

    ' store cookie from SW
    iCookie = Cookie

    'inform SW about the object that contains the callbacks
    bRet = iSldWorks.SetAddinCallbackInfo(App.hInstance, Me, iCookie)

    ' extract bitmaps from resources
    Set pictNone = LoadResPicture(101, vbResBitmap)
    Set pictPart = LoadResPicture(102, vbResBitmap)
    Set pictAssy = LoadResPicture(103, vbResBitmap)
    Set pictDraw = LoadResPicture(104, vbResBitmap)

    ' get temp filenames for bitmaps
    fileNone = fso.GetTempName
    filePart = fso.GetTempName
    fileAssy = fso.GetTempName
    fileDraw = fso.GetTempName

    ' save bitmaps to disk
    SavePicture pictNone, fileNone
    SavePicture pictPart, filePart
    SavePicture pictAssy, fileAssy
    SavePicture pictDraw, fileDraw

    bRet = iSldWorks.AddMenuItem3(swDocNONE, iCookie, "DocNONE_Item@Sample", -1, "DocNONE_Item", "DocNONE_ItemUpdate", "Sample|DocNONE_Item hint string", fileNone)

    bRet = iSldWorks.AddMenuItem3(swDocPART, iCookie, "DocPART_Item@Sample", -1, "DocPART_Item", "DocPART_ItemUpdate", "Sample|DocPART_Item hint string", filePart)
    bRet = iSldWorks.AddMenuItem3(swDocASSEMBLY, iCookie, "DocASSEMBLY_Item@Sample", -1, "DocASSEMBLY_Item", "DocASSEMBLY_ItemUpdate", "Sample|DocASSEMBLY_Item hint string", fileAssy)
    bRet = iSldWorks.AddMenuItem3(swDocDRAWING, iCookie, "DocDRAWING_Item@Sample", -1, "DocDRAWING_Item", "DocDRAWING_ItemUpdate", "Sample|DocDRAWING_Item hint string", fileDraw)

    ' remove temporary bitmap files
    fso.DeleteFile fileNone, True
    fso.DeleteFile filePart, True
    fso.DeleteFile fileAssy, True
    fso.DeleteFile fileDraw, True

    SwAddin_ConnectToSW = True
    End Function

    Private Function SwAddin_DisconnectFromSW() As Boolean
    Dim bRet As Boolean

    'Remove any UI that was added earlier
    bRet = iSldWorks.RemoveMenu(swDocNONE, "Sample", "")

    bRet = iSldWorks.RemoveMenu(swDocPART, "Sample", "")
    bRet = iSldWorks.RemoveMenu(swDocASSEMBLY, "Sample", "")
    bRet = iSldWorks.RemoveMenu(swDocDRAWING, "Sample", "")

    Set iSldWorks = Nothing

    SwAddin_DisconnectFromSW = True
    End Function

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Callback routines for SW
    Public Sub DocNONE_Item()
    MsgBox "Sample|DocNONE_Item menuitem was called"
    End Sub

    Public Function DocNONE_ItemUpdate() As Long
    'Return the state information for the menu item
    ' 0 - Disabled and unchecked
    ' 1 - Enabled and unchecked (default when update routine does not exist)
    ' 2 - Disabled and checked
    ' 3 - Enabled and checked

    DocNONE_ItemUpdate = 1
    End Function

    Public Sub DocPART_Item()
    MsgBox "Sample|DocPART_Item menuitem was called"
    End Sub

    Public Function DocPART_ItemUpdate() As Long
    'Return the state information for the menu item
    ' 0 - Disabled and unchecked
    ' 1 - Enabled and unchecked (default when update routine does not exist)
    ' 2 - Disabled and checked
    ' 3 - Enabled and checked

    DocPART_ItemUpdate = 1
    End Function

    Public Sub DocASSEMBLY_Item()
    MsgBox "Sample|DocASSEMBLY_Item menuitem was called"
    End Sub

    Public Function DocASSEMBLY_ItemUpdate() As Long
    'Return the state information for the menu item
    ' 0 - Disabled and unchecked
    ' 1 - Enabled and unchecked (default when update routine does not exist)
    ' 2 - Disabled and checked
    ' 3 - Enabled and checked

    DocASSEMBLY_ItemUpdate = 1
    End Function

    Public Sub DocDRAWING_Item()
    MsgBox "Sample|DocDRAWING_Item menuitem was called"
    End Sub

    Public Function DocDRAWING_ItemUpdate() As Long
    'Return the state information for the menu item
    ' 0 - Disabled and unchecked
    ' 1 - Enabled and unchecked (default when update routine does not exist)
    ' 2 - Disabled and checked
    ' 3 - Enabled and checked

    DocDRAWING_ItemUpdate = 1
    End Function更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • any one good at VB kind?
      • up 上去,等....
    • Thing you should read before asking a question.

      Use easily readable formats

      Post your question in a format that is easy to read. stating "The problem is..."

      Be precise

      When asking for help because something does not work, be precise in describing what is happening. This includes a detailed description of what you did, and a full copy of the output.

      Other information that you should consider including

      * which operating system you are using;

      * which Software version you are using;

      * the exact output/error message that is produced.

      • hi, 谢谢轮胎兄的指点, thing is i even don't understand what it is, i just copy from net, and which is add a menu bar on Solidworks---3d CAD software.
        • 最起码,要告诉别人你做了些什么,有什么结果吧。从你的问题,想帮都无从下手。
          • 其实,我什么都不会,我只是应用SOLIDWORKS(sw)软件而已,如果问题改为如何给sw 添加菜单项会否更容易一点?