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.

联系我们

联系原厂或当地办公室

You are reporting an issue with the following selected text
and/or image within the active document:
Altium Designer 免费试用
Altium Designer Free Trial
我们开始吧!首先,您或者您的公司已经在使用Altium Designer了吗?

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

既然您在使用Altium Designer,为何仍需要试用?

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

好的,实际上您无需下载一个试用版本。

点击下方按钮下载最新版本的Altium Designer安装包

下载Altium Designer 安装包

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

填写下方表格,获取Altium Designer最新报价。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

如果您是Altium维保期内客户,您不需要下载试用版本。

如果您不是Altium维保客户,请填写下方表格免费试用。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

您为何想要试用Altium Designer?

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

那您来对地方了!请填写下方表格申请试用吧。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

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.

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

好的,您可以下载免费的Altium Designer Viewer查看文档,有效期6个月。

请填写下方表格申请。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

好棒!创作是一件超酷的事情,我们可以为您提供完美的设计软件。

Upverter是一个社区导向的交流平台,专为您这样的创客量身定做。

点击这里看看吧!

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

好的,您可以下载免费的Altium Designer Viewer查看文档,有效期6个月。

请填写下方表格申请。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。