4 Replies Latest reply on May 3, 2017 11:05 AM by Lee CS Young

    Menu Command C# PDM API - Right click white space (no files)

    Sean Donnelly

      I have an entire code ready for when someone selects a file via right click. I want to add some extra code (message box and maybe something else) when they do not choose a file or folder i.e. the "white space". How would I go about doing this? I want it to basically follow the line of "Oh hey, nothing was selected, I need to give the user this". I have a small sample to get the point across below. Let me know what you think. It crashes explorer at the if statement I believe because it is based on the mlObjectID1.


      case EdmCmdType.EdmCmd_Menu:
                              //edmVault.MsgBox(0, " $safeprojectname$", EdmMBoxType.EdmMbt_OKOnly, "SolidWorks EPDM Addin");
                              //Inspection Request
                              if (poCmd.mlCmdID == 1000) //This makes sure the menu command ID was 100, which means your addin was the one called  
                                  object CreatedBy = null; //Create a variable to hold the model no.  
                                  object Desc1 = null;
                                  object Desc2 = null;
                                  object Rev = null;
                                  object StockingType = null; //Create a variable to hold the model no.
                                  IEdmFolder5 srcFolder = null;
                                  string fileNoExt = null;
                                  IEdmVault12 myVault = (IEdmVault12)poCmd.mpoVault; //Cast the vault to an Iedmvault12 object for latest functionality 
                                  if ((((EdmCmdData)ppoData.GetValue(0)).mlObjectID1) != 0) //mlObjectID1 will be 0 if a folder was selected and the ID of the file if a file was selected during a menu command  
                                      IEdmFile5 myfile = (IEdmFile10)myVault.GetObject(EdmObjectType.EdmObject_File, (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1));//Get the file object  
                                      string extension = Path.GetExtension(myfile.Name);
                                      if (extension != ".DXF" && extension != ".dxf")
                                          MessageBox.Show("You must select a DXF drawing file.");
                                      MessageBox.Show("This was not a file or folder.");
                              //Basic Drafting Update