Teigha Mechanical: Bill Of Materials Physical Data Model in OdDbDatabase

Andrii Morozov

October 31, 2017

Bill Of Materials is a table that holds all parts and components with corresponding data and attributes. The logical representation is quite easy to understand but the physical data model of a BOM table is a complex concept that includes components, parts and data containers.

Mechanical dictionary

All common data that relates to Teigha Mechanical is located in a couple of dictionaries, particularly AcmDictionary.

image1

AcmDictionary in the database

AcmDictionary holds data related to Bill Of Materials: AcmBOM dictionary and AcmDataDictionary. Also the dictionary holds some common data such as the standards dictionary.

image2

BOM dictionary

Mechanical data dictionary

Another important dictionary is the AcmBOMDATA dictionary. This dictionary relates to AcmDataDictionary. Basically, AcmBOMDATA holds data containers for BOM rows and BOM tables.

A data container can be any of the following types: DataEntry, DataEntryPart, or DataEntryBlock. The AcmDataDictionary class handles and works with BOM Data:

OdResult  append(AcmDataEntryPtr pDataEntry, OdDbObjectId& newObjId);
OdResult createDataEntryFor(AcmBomPtr& pBom, const OdDbObjectId& targetId, OdDbObjectId& objId);
OdResult  createDataEntryFor2DCompDef(const OdDbObjectId& targetId, OdDbObjectId& objId);
OdResult  createDataEntryFor(const OdDbBlockTableRecordPtr& pBlockTableRecord, OdDbObjectId& objId);
OdResult getDataEntryByCompDefId(const OdDbObjectId& compDefId, OdDbObjectId& dataEntryId) const;
  • append(AcmDataEntryPtr pDataEntry, OdDbObjectId& newObjId) — Adds a new data entry container to an existing dictionary.
  • createDataEntryFor() — This group of methods creates new data entry containers.
  • getDataEntryByCompDefId(const OdDbObjectId& compDefId, OdDbObjectId& dataEntryId) — Returns the data entry container for a component definition object.
image3

BOMData dictionary and DataEntries

DbInfo service class

AcadmDbInfo is a service class that works with AcmDataDictionary. This service class is designed to make working with Teigha Mechanical dictionaries easier.

OdDbObjectId acmDictionaryId();
OdDbObjectId bomDictionaryId();
OdDbObjectId dataDictionaryId();
OdDbObjectId createBomDictionary();
  • acmDictionaryId() — Returns the AcmDictionary OdDbObjectId for the current database.
  • bomDictionaryId() — Returns the AcmBOM OdDbObjectId for the current database.
  • dataDictionaryId() — Returns the AcmBOMDATA OdDbObjectId for the current database.
  • createBomDictionary() — Creates a new AcmBOM dictionary for the current database if it's missing.

BOM objects

The AcmBom class represents a Bill Of Materials table object. An AcmBom object holds a data entry container with appropriate data for the BOM table and BOM rows that represent BOM items.

OdString                          name() const;
OdDbHardPointerId                 dataEntryId() const;
void                              setDataEntryId(OdDbHardPointerId objId);
void                              setName(OdString name);
bool                              isExpandedBOM() const;
OdInt16                           itemNumberStep() const;
OdString                          itemNumberStart() const;
void                              setItemNumberStart(const OdString& itemNumberStart);
void                              setItemNumberStep(OdInt16 itemNumberStep);
  • dataEntryId() — Returns the BOM table data container.
  • setDataEntryId(OdDbHardPointerId objId) — Sets a data container for the BOM table.
  • name() — Returns the name of the BOM table.
  • setName(OdString name) — Sets a name for the BOM table.
  • isExpandedBOM() — Returns true if the BOM is expanded, false if structured.
  • itemNumberStep() — Returns the number step of the item attribute for the BOM table.
  • itemNumberStart() — Returns the first number of the attribute for the BOM table.
  • setItemNumberStart(const OdString& itemNumberStart) — Sets an item number step for the BOM table.
  • setItemNumberStep(OdInt16 itemNumberStep) — Sets the first number for the BOM table.

BOM rows

The AcmBomRow class represents a BOM table item. BomRow also holds a data container.

OdString                 getItemName() const;
OdDbHardPointerId        getDataEntryId() const;
virtual bool             isVisible() const;
bool                     isToExpand() const;
OdInt32                  getSortPriority();
void                     setSortPriority(OdInt32 priority);
  • getItemName() — Returns the item name.
  • getDataEntryId() — Returns the data container.
  • isVisible() — Returns true if the item is visible.
  • isToExpand() — Returns true if the item in an expanded BOM.
  • getSortPriority() — Returns the sort priority.
  • setSortPriority(OdInt32 priority) — Sets the sort priority for the item.
image4

BomRow and Bom

Conclusion

A Bill Of Materials is a set of dictionaries that has a subset of BOM items (rows) and data containers (data entries). Rows and entries are connected to each other, and rows are connected to components.