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