AnsweredAssumed Answered

how to AddMenuItem in SW2015

Question asked by Win Lai on Dec 7, 2016
Latest reply on Dec 7, 2016 by Win Lai

dear all,

I have some question need you help.

when I use "AddMenuItem4" inSolidWorks2015 ,and the SolidWorks crash when run the code:

 

menu = iSwApp.AddMenuItem4(swDocumentTypes_e.swDocPART, Cookie, "NewMenu", 0, "callback", 1, "tip", "")

 

The code modify from SolidWorks2015 API SDK as bollow :

======================================================================================================================

    Function ConnectToSW(ByVal ThisSW As Object, ByVal Cookie As Integer) As Boolean Implements SolidWorks.Interop.swpublished.SwAddin.ConnectToSW

        iSwApp = ThisSW

        addinID = Cookie

 

 

        Dim menu As Boolean

        menu = iSwApp.AddMenuItem4(swDocumentTypes_e.swDocPART, Cookie, "NewMenu", 0, "callback", 1, "tip", "")

 

 

        ' Setup callbacks

        iSwApp.SetAddinCallbackInfo(0, Me, addinID)

 

 

        ' Setup the Command Manager

        iCmdMgr = iSwApp.GetCommandManager(Cookie)

        AddCommandMgr()

 

 

        'Setup the Event Handlers

        SwEventPtr = iSwApp

        openDocs = New Hashtable

        AttachEventHandlers()

 

 

        'Setup Sample Property Manager

        AddPMP()

 

 

        ConnectToSW = True

    End Function

====================================================================================================================

 

thank you very much!!!

Outcomes