Check the items referenced in the BOM

Check the items referenced in the BOM

marcelo.zatteraBGGNH
Contributor Contributor
210 Views
2 Replies
Message 1 of 3

Check the items referenced in the BOM

marcelo.zatteraBGGNH
Contributor
Contributor

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.

BOM Functions Reference 

 

I would be grateful if someone could help me in any way.

0 Likes
211 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor

There are few things

  • If it is external application (exe), try to convert it to add-in.
  • I don't know the type of dtRef. Try to eliminate API calls and fill it at once when possible.
  • Is RecursiveReference the same as ReferenciaRecursiva?
  • In external application try to use ApprenticeServer instead of full Inventor.
0 Likes
Message 3 of 3

marcelo.zatteraBGGNH
Contributor
Contributor

Hi @Michael.Navara 

  • If it is external application (exe), try to convert it to add-in.
    • My application is an exe.
  • I don't know the type of dtRef. Try to eliminate API calls and fill it at once when possible.
    • dtRef is a DataTable.
  • Is RecursiveReference the same as ReferenciaRecursiva?
    • Yes, it's the same, I'm forgot to change in example.
  • In external application try to use ApprenticeServer instead of full Inventor.
    • I believe that this will not allow me to do what I want.

Thanks.

0 Likes