Message 1 of 3
Check the items referenced in the BOM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone!
I have an application that checks if any item in the structure is in reference, it is working, the problem is that if the structure is too big, it takes a long time to execute.
Here is my source code.
private void button10_Click(object sender, EventArgs e)
{
DataTable dtRef = new DataTable();
dtRef.Columns.Add("CODE");
dtRef.Columns.Add("DESCRIPTION");
AssemblyDocument oAssemDoc = (AssemblyDocument)invApp.ActiveDocument;
RecursiveReference(oAssemDoc.ComponentDefinition.Occurrences);
MessageBox.Show("Done!");
}
private void RecursiveReference(ComponentOccurrences Occurrences)
{
try
{
foreach (ComponentOccurrence oOcc in Occurrences)
{
if (oOcc.BOMStructure == Inventor.BOMStructureEnum.kReferenceBOMStructure)
{
Document doc = oOcc.Definition.Document;
Property oDescription = doc.PropertySets["Design Tracking Properties"]["Description"];
Property oPartNumber = doc.PropertySets["Design Tracking Properties"]["Part Number"];
dtRef.Rows.Add(new Object[] { oPartNumber.Value, oDescription.Value });
}
if (oOcc.DefinitionDocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
RecursiveReference((ComponentOccurrences)oOcc.SubOccurrences);
}
}
}
catch (Exception ex) { }
}
I have been doing some research to try to reduce this time and one of the ideas would be to export the BOM to Excel and then use some framework to read Excel and identify items in reference, but the problem is that there is no possibility to export the BOM with the items in reference.
I would be grateful if someone could help me in any way.