Hide Table of Contents
Rename Method (IEdmBomView4)

Renames this named BOM.

Syntax

Visual Basic (Declaration) 
Sub Rename( _
   ByVal bsFileName As System.String _
) 
C# 
void Rename( 
   System.string bsFileName
)
C++/CLI 
void Rename( 
&   System.String^ bsFileName
) 

Parameters

bsFileName
New file name of named BOM

Example

//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);

            }

        }

    }

}

 

Remarks

Named BOMs are saved as:

     file_name.sldext.version.BOM

Be sure to use the correct format when specifying bsFileName. For example, if you get assembly.sldasm, then to rename its BOM set bsFileName to:

    assembly_renamed.sldasm.1.BOM

 

See Also

Availability

SOLIDWORKS PDM Professional 2022


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Rename Method (IEdmBomView4)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:




x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2022 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.