Hello all,
im trying to create an AddIn for EPDM to delete preselected Files in a Folder. I´m using the code from a sample AddIn which shows a messagebox where the selected files are shown with ID and Filename.
Here the code:
<p>using System;</p><p>using System.Collections.Generic;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Threading.Tasks;</p><p>using EdmLib;</p><p>using Microsoft.VisualBasic;</p><p></p><p>namespace EpdmAddInFunktionen</p><p>{</p><p> public class Class1 : IEdmAddIn5</p><p> {</p><p> public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)</p><p> {</p><p> //Specify information to display in the add-in's Properties dialog box </p><p> poInfo.mbsAddInName = "AddInName";</p><p> poInfo.mbsCompany = "CompanyName";</p><p> poInfo.mbsDescription = "Delete " + Constants.vbLf + "Add " + Constants.vbLf + "Change " + Constants.vbLf + "etc. ";</p><p> poInfo.mlAddInVersion = 1;</p><p></p><p> //Specify the minimum required version of SolidWorks Enterprise PDM</p><p> poInfo.mlRequiredVersionMajor = 5;</p><p> poInfo.mlRequiredVersionMinor = 2;</p><p></p><p> //Register menu commands; SolidWorks Enterprise PDM passes command IDs, 1000 and 1001, </p><p> //to IEdmAddIn5::OnCmd to indicate which command the user selects</p><p> poCmdMgr.AddCmd(1000, "Delete", (int)EdmMenuFlags.EdmMenu_Nothing, "Delete File", "Delete", 0, 99);</p><p> poCmdMgr.AddCmd(1001, "Add", (int)EdmMenuFlags.EdmMenu_MustHaveSelection, "Add File", "Add", 1, 99);</p><p> }</p><p></p><p> public void OnCmd(ref EdmCmd poCmd, ref Array ppoData)</p><p> {</p><p></p><p> IEdmVault5 vault = new EdmVault5() as IEdmVault5;</p><p> vault.Login("admin", "xxx", "VaultName");</p><p> </p><p> //Handle the menu command</p><p> {</p><p> string CommandName = null;</p><p> if (poCmd.mlCmdID == 1000)</p><p> {</p><p> CommandName = "Command1.";</p><p> }</p><p> else</p><p> {</p><p> CommandName = "Command2.";</p><p> }</p><p> //Retrieve the bounds of the array containing the selected files and folders </p><p> int index = 0;</p><p> int last = 0;</p><p> index = Information.LBound(ppoData);</p><p> last = Information.UBound(ppoData);</p><p> string StrID = null;</p><p></p><p> //Create a message showing the names and IDs of all selected files and folders </p><p> string message = null;</p><p> message = "Sie haben diese Dateien zum löschen selektiert: " + Constants.vbLf;</p><p> while (index <= last)</p><p> {</p><p> if (((EdmCmdData)ppoData.GetValue(index)).mlObjectID1 == 0)</p><p> {</p><p> message = message + "Folder: (ID=";</p><p> StrID = ((EdmCmdData)ppoData.GetValue(index)).mlObjectID2.ToString();</p><p> message = message + StrID + ") ";</p><p> }</p><p> else</p><p> {</p><p> message = message + "File: (ID=";</p><p> StrID = ((EdmCmdData)ppoData.GetValue(index)).mlObjectID1.ToString();</p><p> message = message + StrID + ") ";</p><p> }</p><p></p><p> message = message + ((EdmCmdData)ppoData.GetValue(index)).mbsStrData1 + Constants.vbLf;</p><p> index = index + 1;</p><p> }</p><p></p><p> //Display the message</p><p> EdmVault5 v = default(EdmVault5);</p><p> v = (EdmVault5)poCmd.mpoVault;</p><p> v.MsgBox(poCmd.mlParentWnd, message, EdmMBoxType.EdmMbt_OKOnly, CommandName);</p><p> </p><p> }</p><p></p><p> }</p><p> }</p><p>}</p>How can I change/add the code to delete the selected files in the folder?
Any help would be appreciated
Cheers Mario
SolidworksApi macros