BOM Engine Interfaces

Modified by Rob Evans on Apr 17, 2018

The Altium SDK Bill Of Materials (BOM) Interfaces allow the creation and management of project BOM data and associated parameters.

The BOM 2.0 Engine is available in the Altium SDK 4.0. Its main class is the BOM Manager (IBomManager) , called for a specific document data source type by the IBomManagerFactory ( EDP.Utils.GetBomManagerFactory()).

A BOM 2.0 Engine example project is included with the Altium Developer installation. In the default Altium Developer installation, the C# (CSharp) BOMPanel example location is: C:\ProgramData\Altium\[host Altium software]\Extensions\Altium Developer\SDK4.0\CSharp\Examples\BOMPanel

BOM usage via the Altium SDK

Start

The very entry point for using the BOM (Bill Of Materials) via the Altium SDK is IBomManagerFactory.

To get an instance of the BOM Factory, use  EDP.Utils.GetBomManagerFactory() method.

Get Bill Of Materials

The Bill Of Materials object is represented by an instance of IBomManager/IActiveBomManager:

  • for any document (SCH / PCB / BOMDOC) as a source of components:
    IBomManagerFactory.GetManagerForDocument(srcDoc)
  • for SCH / BOMDOC as a source of components with a PCB document as an additional source of PCB parameters:
    IBomManagerFactory.GetManagerForDocumentPcb(srcDoc, pcbDoc)
  • for a whole project:
    IBomManagerFactory.GetManagerForProject(project)
  • for a whole project with a PCB document as an additional source of PCB parameters:
    IBomManagerFactory.GetManagerForProjectPcb(project, pcbDoc)

IBomManager / IActiveBomManager

Depending on the options above, you will get an instance of EDP.IBomManager or EDP.IActiveBomManager.

To check which one you have, cast the instance to IActiveBomManager:
var activeBomManager = bomManager as IActiveBomManager;
...and check the result for a null.

Retrive the BOM content

Get rows

IBomComponentList components = bomManager.GetSchema().GetComponents()

IBomComponentList is a list of IBomComponent

Get 'original' components of row

First, check if a row (IComponent) is actually a group – that is, it contains more than one component:  row.IsGroup()

Then cast it to a group and get its components: row.AsGroup().GetComponents()

Get row columns (parameter) values

Getting column parameter values for a given IBomComponent row.

Get row parameters dictionary:
IBomParameterDictionary params = row.GetParameters()

...and use the dictionary’s methods like:
bool TryGetParameter(string argName, out IBomParameter argParameter)

...or:
GetStrValue(..), GetIntValue(..);

Get column aliases

For an ActiveBOM document, column aliases (custom names) can be specifed.

If you have IActiveBomManager (not just the IBomManager) you are able to access:
string aliases = activeBomManager.GetOptions().GetColumnsAliases()

This string should be parsed – split with a ‘|’ char and then received pairs with ‘=’

Get list of all columns (parameters)

IBomParameterDefinitionList columns = bomManager.GetSchema().GetParameterDefinitions()

Get list of custom columns

For an ActiveBOM document, Custom Columns can be created. They are presented in IBomParameterDefinitionList along with other (auto-generated) columns. If a dedicated list is needed for some reason, it can be obtained with:
activeBomManager.GetOptions().GetCustomColumns()

Set up the required BOM

The point where you can configure the BOM is:
IBomManagerOptions o = bomManager.GetOptions()

...or for ActiveBOM:
IActiveBomManagerOptions ao = activeBomManager.GetOptions();

Flat view mode

o.SetAutoGroup(false);
o.SetGroupOrder("");
ao?.SetMultiVariant(false);

Consolidated

o.SetAutoGroup(true);
o.SetGroupOrder("");
ao?.SetMultiVariant(true);

Sorting

Assume there is a:
IList<Tuple<string, ListSortDirection>> sortOrderParams;

Where the first item is Name of Parameter, and the second is Sort Direction.

...then to apply the following setting to BOM usage:

o.SortOrder.Set(sortOrderParams);
o.AutoSort = sortOrderParams.Count == 0;

Avoid affecting BOMs in the rest of Altium Designer

It's advisable to save the BOM Manager Options before they are modified:

IBomManagerOptions options
var savedState = options.GetState();

When all the required data have been collected, restore the options:
options.RestoreState(savedState);

Using a try-finally clause is recommended.

Modify BOM content

Set line number for row

Setting line numbers is possible for ActiveBOM only:

IActiveBomManager activeBomManager = ... // create BomManager for .BomDoc
IBomComponent component = ... // find component in BOM schema
var catalogId = component.GetParameters().GetStrValue("%CATALOGID%");
var catalog = activeBomManager.GetCatalog();
var catalogItem = catalog.FindItem(catalogId);
catalogItem.SetLineNumber("...");

To update BOM schema after changing line numbers in catalog items, call bomManager.UpdateSchema (note - this will recreate the whole BOM schema).

Add custom row

To add a custom row in ActiveBOM:

IActiveBomManager activeBomManager = ... // create BomManager for .BomDoc
var catalog = activeBomManager.GetCatalog();
var catalogItem = catalog.AddCustomRow();

To set parameters for a created custom row use catalogItem methods SetComment, SetDescription, SetLineNumber (or GetParameters().SetValue methods to set any parameter).

To update BOM schema after a creating custom row call bomManager.UpdateSchema.

Save ActiveBOM document

After any modification you may wish to save the ActiveBOM document (*.BomDoc), which can be done as follows:

IDocument document = ... // get ActiveBOM document
var serverDocument = document.DM_ServerDocument();
serverDocument.DoFileSave(document.DM_DocumentKind());
Found an issue with this document? Highlight the area, then use Ctrl+Enter to report it.

Contact Us

Contact our corporate or local offices directly.

You are reporting an issue with the following selected text
and/or image within the active document:
ALTIUM DESIGNER FREE TRIAL
Altium Designer Free Trial
Let’s get started. First off, are you or your organization already using Altium Designer?

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

In that case, why do you need an evaluation license?

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

Got it. You actually don’t need an evaluation license for that.

Click the button below to download the latest Altium Designer installer.

Download Altium Designer Installer

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

Please fill out the form below to get a quote for a new seat of Altium Designer.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

If you are on Altium Subscription, you don’t need an evaluation license.

If you are not an active Altium Subscription member, please fill out the form below to get your free trial.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

Why are you looking to evaluate Altium Designer?

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

You came to the right place! Please fill out the form below to get your free trial started.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

Great News!

Valid students can get their very own 6-month Altium Designer Student License for FREE! Just fill out the form below to request your Student License today.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

Got it. You can download a free Altium Designer Viewer license which is valid for a 6 months.

Please fill out the form below to request one.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

That’s great! Making things is awesome. We have the perfect program for you.

Upverter is a free community-driven platform designed specifically to meet the needs of makers like you.

Click here to give it a try!

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

Got it. You can download a free Altium Designer Viewer license which is valid for a 6 months.

Please fill out the form below to request one.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.