Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get the parts list from the BOM

1 REPLY 1
SOLVED
Reply
Message 1 of 2
bsee1
491 Views, 1 Reply

Get the parts list from the BOM

Searching the forums, it seems like most people output the whole BOM.  I only want to data in the Part Number column, preferably as a list of strings.

 

Here's what I have so far:

foreach (Sheet oSheet2 in aDoc.Sheets)
{
    for (int i = 1; i < (oSheet2.PartsLists.Count+1); i++)
    {
        var oPartsList = oSheet2.PartsLists[i];
        for(int k = 1; k < oPartsList.PartsListColumns.Count+1; k++)
        {
            if (oPartsList.PartsListColumns[k].Title.Equals("PART NUMBER"))
            {
             //what goes here???
                                
            }
        }
    }
}

 Can anyone point me in the right direction?

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Tags (3)
1 REPLY 1
Message 2 of 2
bsee1
in reply to: bsee1

I found someone else's post from about 5 years back.  Here's some updated code in C# for anyone that runs into the same problem.  This looks for the part number column int he table, then gets the value of each cell in that column.

  

List<string> partsList = new List<string> ();
DrawingDocument aDoc = (DrawingDocument)m_inventorApplication.ActiveDocument;
Sheet oSheet = aDoc.ActiveSheet;

PartsList oPartsList = oSheet.PartsLists[1];
int counter = 0;
foreach (PartsListColumn oColumn in oPartsList.PartsListColumns)
{
	counter++;
	if(oColumn.Title == "PART NUMBER")
	{
		foreach (PartsListRow oRow in oPartsList.PartsListRows)
		if (oRow[counter].Value != null)
		{
			partsList.Add (oRow[counter].Value);
		}
	}
}
partsList.Distinct();

 

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report