4 Replies Latest reply on May 1, 2014 9:44 AM by Mike Gann

    Task Add-in - Show on menus

    Mike Gann

      I'm working with the Task Add-in  example located here:

       

      http://help.solidworks.com/2014/English/api/epdmapi/tasksample.htm

       

      I'm able to compile it and so far the example looks to be working. However I can't get the Task Add-in to show on any menu. Below is the code from the onTaskSetup procedure that should add it to the menu.

       

      I've tried setting the flag (cmds(0).mlEdmMenuFlags = EdmMenuFlags.EdmMenu_ShowInMenuBarAction) to various values but I still can't get this to show up anywhere.

       

      Thanks,

       

      Mike

       

      Sub OnTaskSetup(ByRef poCmd As EdmCmd, ByRef ppoData As System.Array)

       

       

              Dim props As IEdmTaskProperties

              props = poCmd.mpoExtra

       

       

              'Turn on some properties, e.g., the task can be launched during a

              'state change, can extend the details page, is called when the

              'task is launched, and supports scheduling

              props.TaskFlags = EdmTaskFlag.EdmTask_SupportsChangeState + EdmTaskFlag.EdmTask_SupportsDetails + EdmTaskFlag.EdmTask_SupportsInitExec + EdmTaskFlag.EdmTask_SupportsScheduling

       

       

              'Set menu commands that launch this task from Windows Explorer

              Dim cmds(0) As EdmTaskMenuCmd

              cmds(0).mbsMenuString = "Run the test task"

              cmds(0).mbsStatusBarHelp = "This command runs the task add-in"

              cmds(0).mlCmdID = 1

              cmds(0).mlEdmMenuFlags = EdmMenuFlags.EdmMenu_ShowInMenuBarAction

              props.SetMenuCmds(cmds)

       

       

              'Add a custom setup page; SetupPage is a user control with an

              'edit box; SetupPage::LoadData populates the edit box from a

              'variable in IEdmTaskProperties; saving of properties is handled

              'by OnTaskSetupButton

              currentSetupPage = New SetupPage

              currentSetupPage.CreateControl()

              currentSetupPage.LoadData(poCmd)

       

       

              Dim pages(0) As EdmTaskSetupPage

              pages(0).mbsPageName = "Test Add-in page"

              pages(0).mlPageHwnd = currentSetupPage.Handle.ToInt32

              pages(0).mpoPageImpl = currentSetupPage

       

       

              props.SetSetupPages(pages)

          End Sub

        • Re: Task Add-in - Show on menus
          Artem Taturevych

          Try

           

          cmds(0).mlEdmMenuFlags = EdmMenuFlags.EdmMenu_ContextMenuItem

           

          This works for me in my task add-in.

          ______________________________________________

          Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

           

          IC3DSteel – New Steel Solution for SolidWorks

          translationXpert – SolidWorks files language translator

          LinkedIn - SolidWorks API Group

            • Re: Task Add-in - Show on menus
              Mike Gann

              Hi Artem -

               

              This was one of the first things I tried. But just to be sure I just tried it again. I followed these steps after rebuilding the DLL

               

              1. In Administrator tool - deleted the task which uses the Add-In

              2. In the Administrator tool - removed the Add-in (previous build)

              3. On my PC I deleted the plug-in folder to be sure I would get the newly rebuilt DLL

              4. In Administrator tool - Added new add-in using the updated DLL

              5. On my PC - ran task host configuration to allow the task to run on my PC

              6. In Administrator tool, created new task using the just added Task Add-in from step 4

              7. On my PC, navigated to a file in the vault and right mouse clicked to bring up contect menu.

               

              It all looks right and it seems like it should work, but it doesn't.

               

              Thanks,

               

              Mike

                • Re: Task Add-in - Show on menus
                  Artem Taturevych

                  Hi Mike,

                   

                  That's strange. May be you are using old add-in cache (please note that the add-ins loaded in ePDM are not loaded from the VS output folder - so just clearing the bin folder is not enough). Can you add some message box to your add-in to make sure that the right version is loaded. You may also need to clear the cache. To do this you need to kill 'explorer.exe' process and then start this process again. You may also need to clear the add-ins local cache: C:\Users\<UserName>\AppData\Local\SolidWorks\SolidWorks Enterprise PDM\Plugins\<VaultName> and delete <AddIn GUID> folder.

                   

                  But this function definitely working for me (EPDM 2013). I'm not using the example but my own architecture but it doesn't differ too much from the sample you mentioned (but I'm adding the commands at the very end of the function after the SetSetupPages). And I also do not see any errors in your workflow. As you correctly noted you should see the command menu.

                   

                  Thanks,

                  Artem

                  ______________________________________________

                  Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                   

                  IC3DSteel – New Steel Solution for SolidWorks

                  translationXpert – SolidWorks files language translator

                  LinkedIn - SolidWorks API Group

                    • Re: Task Add-in - Show on menus
                      Mike Gann

                      Hi Artem -

                       

                      Again, thanks for the help. I tried it again this morning and with a fresh set of eyes I found my mistake. When I was setting up the new task I didn't give myself permission to run the task! Thats why the menu choice wasn't showing as expected. Frustrating to miss such simple things and bang your head against the wall.......

                       

                      Thanks,

                       

                      MIke