Community
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?
Solved! Go to Solution.
Solved by bsee1. Go to Solution.
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();