Enterprise PDM, SolidWorks Enterprise PDM, Tips & Tricks

API TIP: Getting BOMs using SolidWorks Enterprise PDM API

API TIP: Getting BOMs using SolidWorks Enterprise PDM API

23 July, 2009

664 Comments

API Tip

SolidWorks Enterprise PDM user interface provides direct access to the BOMs. However, If you need to access a BOM using a program, here is how it can be done. Before you can get a computed or derived BOM (bill of materials) using SolidWorks Enterprise PDM API 2009 and later, you must get the layout ID of the BOM. The following code shows how to do this in a VB.NET add-in:

Dim edmVault As IEdmVault7 = TryCast(poCmd.mpoVault, IEdmVault7) Dim edmFile As IEdmFile7 Dim i As Long Dim edmBOMManager As IEdmBomMgr Dim data As EdmCmdData data = ppoData(0) ‘ Get the SolidWorks Enterprise PDM object edmFile = edmVault.GetObject(EdmObjectType.EdmObject_File, Data.mlObjectID1) ‘ Get the BOM manager utility, then ‘ get an array of BOM layouts for the file Dim edmBOMArray() As EdmBomLayout edmBOMManager = edmVault.CreateUtility(EdmUtility.EdmUtil_BomMgr) edmBOMManager.GetBomLayouts(edmBOMArray) ‘ Using the layout ID of the BOM, get the BOM interface, ‘ which provides access to the BOM view, for each ‘ BOM in the file For i = 0 To UBound(edmBOMArray) Dim edmBOMView As IEdmBomView edmBOMView = edmFile.GetComputedBOM(edmBOMArray(i).mlLayoutID, _ edmFile.CurrentVersion, “default”, 0) Next
>> SIGN UP for SolidWorks Express Newsletter and get the tips and tricks delivered into your inbox every two weeks!

This post was submitted by SolidWorks Express.

You may also like

664 Comments »

You must be logged in to post a comment.