Structured bill of material returns just the top level assembly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm working on a standalone C# program that uses Inventor Apprentice API. It opens the top level assembly, loops through its BOM rows in Structured View and displays them in a DataGridView.
For a couple of assemblies, the BOMRowsCount (in the below code) is just 1 ( the top-level assembly), whereas if I change the BOMViewType to 'Model Data' or 'Parts Only', it shows up all the BOMRows.
When I open the Structured View tab of Bill of Materials of that assembly in Inventor UI, I can see all the parts & subassemblies listed. But the API fails to retrieve the BOMRows and it doens't throw any exception either.
I don't know what's special/wrong about these assemblies or there is a better way of implementation.
I'm not very familiar with Inventor APIs, any help on better understanding of this behaviour is appreciated.
var assemblyDoc = inventor.Open(assemblyPath);
var components = (Inventor.AssemblyComponentDefinition)assemblyDoc.ComponentDefinition;
Inventor.BOMView structuredView = null;
try
{
structuredView = components.BOM.BOMViews
.Cast<Inventor.BOMView>()
.Single(view => view.ViewType == Inventor.BOMViewTypeEnum.kStructuredBOMViewType);
var BOMRowsCount = structuredView.BOMRows.Count;
}
catch (InvalidOperationException x)
{
// If zero or more than one structured BOM was found.
throw new InventorStructuredBomException(x);
}
Thanks
Rekha.