Renames this named BOM.
//Preconditions:
//1. Create a C# console application in Visual Studio.
//2. Add references EPDM.Interop.epdm and EPDM.Interop.EPDMResultCode to the project.
//3. Copy the code below to Program.cs.
//4. Change the namespace to match your project name.
//5. Add an assembly with a named BOM to your vault.
//6. Ensure that parameters of Login, and GetFileFromPath match your vault.
//7. Modify the Rename method’s parameter to rename your assembly’s named BOM.
//
//Postconditions:
//1. Refresh your vault view.
//2. Select the assembly with the named BOM in the vault.
//3. Observe the renamed BOM in the BOM dropdown on the Bill of Materials tab.
//Program.cs:
using System;
using EPDM.Interop.epdm;
using EPDM.Interop.EPDMResultCode;
using System.Windows.Forms;
namespace project_name
{
class Program
{
static IEdmVault5 vault1 = null;
static IEdmFile7 aFile;
static string userName = "Admin";
static void Main(string[] args)
{
try
{
vault1 = new EdmVault5();
if (!vault1.IsLoggedIn)
vault1.Login(userName, "password", "JEB12");
IEdmVault7 vault7 = (IEdmVault7)vault1;
IEdmFolder5 ppoRetParentFolder;
aFile = (IEdmFile7)vault1.GetFileFromPath("C:\\Users\\J4M\\Desktop\\JEB12\\test3.sldasm", out ppoRetParentFolder);
EdmBomInfo[] derivedBOMs = null;
aFile.GetDerivedBOMs(out derivedBOMs);
int bomId = derivedBOMs[0].mlBomID;
IEdmBom bom = (IEdmBom)vault7.GetObject(EdmObjectType.EdmObject_BOM, bomId);
EdmBomVersion[] ppoVersions = null;
bom.GetVersions(out ppoVersions);
IEdmBomView4 bomView = (IEdmBomView4)bom.GetView(ppoVersions[ppoVersions.Length - 1].mlVersion);
bomView.Rename("test3_renamed.sldasm.1.BOM");
Console.WriteLine("BOM successfully renamed");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
catch (System.Runtime.InteropServices.COMException ex)
{
var errorType = typeof(EdmResultErrorCodes_e);
if (Enum.IsDefined(errorType, ex.ErrorCode))
MessageBox.Show(String.Format("Error occurred: {0}", Enum.GetName(errorType, ex.ErrorCode)));
else
MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}