BOM Manager Overview

Andrii Morozov

July 11, 2017

A Bill Of Materials (BOM) Manager is a service (service class) that provides an interface for BOM tables, parts, and components in a drawing. A BOM Manager also provides an interface for BOM rows and their data (rows that reflect or contain part data or component data).

This topic contains the following sections:

  • BOM Manager Features and Examples
  • Get All BOM Tables
  • Get a BOM Table by Name
  • Get Part Data by ID
  • Get Item Data for a BOM Row or Part List Group Item by ID

BOM Manager Features and Examples

A Bill of Materials collects all the data from a mechanical structure and parts and represents all the data in the form of a table. A BOM Manager works with different sources of data such as BOM rows and data entries.

A BOM Manager can be created and called as follows:

OdRxClassPtr pService = odrxServiceDictionary()->getAt(L"AcmBOMManager");  
AcmBOMManagerPtr pBOMMgr = pService->create();

A Bill of Materials is a special dictionary. AcmBOM entries can be found in the AcmDictionary section in the list of BOM tables.

image1

Figure 1 – List of BOM Tables

A BOM Manager works with objects in an open drawing or a database, and usually it takes OdDbObjectId as a parameter.

Get All BOM Tables

In the next diagram, there are three BOM types shown in an example file:

  • Main BOM table with the name “MAIN”
  • Assembly BOM table with the name “COMPONENT ASSEMBLY BOM”
  • Title border BOM table with the name “TITLE BORDER BOM”

 


 
image2

To get all BOM tables for an entire drawing and optionally any BOM tables from externally referenced files, use the getAllBomTables() method:

OdResult getAllBomTables(OdDbObjectIdArray& bomIds, bool xrefed, OdDbDatabase * pHostDb);

The first parameter bomIds is an array of OdDbObjectId elements with IDs of BOM tables. The second parameter xrefed defines whether to take BOM tables from externally referenced files. The last parameter pHostDb specifies the database to look in for BOM tables.

Example of using the getAllBomTables() method:

OdDbObjectIdArray objIdArr; 
pBOMMgr->getAllBomTables(objIdArr, useXrefs, pDb);

Example output of the getAllBomTables() method:

List of BOM tables (objIdArr) for the above example file will contain IDs of the BOM Tables:
MAIN                                                                                                                    
COMPONENT ASSEMBLY BOM                                                                                                  
TITLE BORDER BOM

Get a BOM Table by Name

To get a BOM table, use the getBomTable() method that returns an OdDbObjectId of the BOM table with the specified name:

OdResult getBomTable(const OdString& name, OdDbObjectId& bomTableId, OdDbDatabase * pDb);

The first parameter name is a BOM table name. The second parameter bomTableId receives the returned value of the corresponding BOM table object ID. The third parameter pDb is a pointer to the database where the BOM table is located.

Example of using the getBomTable() method:

OdString bomName(L"MAIN");
OdDbObjectId bomTableId;
OdResult result = pBOMMgr->getBomTable(bomName, bomTableId, pDb);
if (result == eOk)
{
  AcmBomPtr pBom = AcmBom::cast(bomTableId.safeOpenObject());
  odPrintConsoleString(pBom->getBomName());
  odPrintConsoleString(L"\n");
  odPrintConsoleString(pBom->getDbHandle().ascii());
  odPrintConsoleString(L"\n");
  return eOk;
}

Example output of the getBomTable() method:

MAIN                                                                                              
34B

Get Part Data by ID

To get part data by ID, use the getPartData() method which works with part references:

OdResult getPartData(const OdDbObjectId& referenceId, OdUInt32& numOfItems, OdMapStringToString& valueMap);

The first parameter referenceId is a part reference object ID. The second parameter numOfItems gets the returned value of the number of items (QTY field). The third parameter valueMap gets a map of property values.

The getPartData() method gets the data contained by a part reference and part reference data entry. It takes the OdDbObjectId of a part reference as an input parameter, and for output parameters it has the number of items (QTY field) and a map of property values. The getPartData() method checks the BOM standard, and if a property is empty, it returns the default BOM standard value (if it exists).

Example of using the getPartData() method:

OdUInt32 numOfItems;
OdMapStringToString valueMap;
result = pBOMMgr->getPartData(partRefObjId, numOfItems, valueMap);

Example output of the getPartData() method (valueMap contents):

BOM_UNITS : ea                                                                                                         
DESCR : description is missing                                                                                          
MATERIAL : Stainless                                                                                                    
NAME : OP9101SL                                                                                                         
STANDARD : ISO                                                                                                          
TOTAL_MASS : =IF(ISBLANK(MASS),BLANK,QTY*MASS)

Get Item Data for a BOM Row or Part List Group Item by ID

To get a BOM row or part list group item data by ID, use the getItemData() method:

OdResult getItemData(const OdDbObjectId& itemId, OdString& itemNo, OdUInt32& numOfItems, OdMapStringToString& valueMap, const OdDbObjectId& bomStdId);

The first parameter itemId is an ID of the object to get item data for. The second parameter itemNo gets a return value of an item number. The third parameter numOfItems gets a return value of the number of items (QTY field). The fourth parameter valueMap gets a map of property values. The fifth parameter bomStdId is the ID of a standard from which to get default BOM standard values.
The workflow is similar to getPartData(). The getItemData() method takes an OdDbObjectId of an object that you want get item data for (a BOM row or a part list group item) as an input parameter. The item number, number of Items (QTY), and map of property values are output parameters.

Example of using the getItemData() method:

OdString itemNo;
OdUInt32 numOfItems;
OdMapStringToString valueMap;
pBOMMgr->getItemData(bomRowId, itemNo, numOfItems, valueMap);

Example output of the getItemData() method:

itemNo: 1
numOfItems: 4 
valueMap contents:
BOM_UNITS : ea
DESCR : description is missing
MATERIAL : Stainless
NAME : OP9101SL
STANDARD : ISO

More BOM-related examples can be found in the Examples|TmBomEx project.

More information in our documentation