Renumber BOM iLogic/API question

Renumber BOM iLogic/API question

AlexFielder
Advisor Advisor
1,248 Views
2 Replies
Message 1 of 3

Renumber BOM iLogic/API question

AlexFielder
Advisor
Advisor

Hi all,

 

As per a client drawing requirement, I have to renumber the BOM in the following order:

 

Parent Assembly = listed but no Item number

Specifications = listed but no Item number (These are simply empty part files with ole references (i.e. linked) to the pdf document stored in Vault)

Sub Assemblies = 1 to 199

Parts = 200 to 499

Content Centre Parts = 500 to 999

 

I'm pretty certain there are examples here showing how to change the BomRow Item number, but I was wondering if using the API/iLogic it is possible to have a BomRow with no Item number, or is (as I suspect) this simply not allowed?

 

Speaking to the Bear EDIT: As I type this I think the answer will be something like:

 

Renumber the parts you need to have numbered however you like but the items which have no number requirement will need to be custom BomRow items otherwise Inventor will throw a "Null Entry" error or such-like.

 

Thanks,

 

Alex.

0 Likes
Accepted solutions (1)
1,249 Views
2 Replies
Replies (2)
Message 2 of 3

AlexFielder
Advisor
Advisor

Now I've hit upon an annoying problem.

 

Using the VBA implementation of BOMQuery() I have the following: C#.NET class (that I call and talk to/from iLogic):

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Inventor;

namespace BOMTool
{
    public class Class1
    {
        public static Inventor.Application m_inventorApplication;
        public List<BomRowItem> BomList = new List<BomRowItem>();
        public static Inventor.Application InventorApplication 
        { 
            get
            {
                return Class1.m_inventorApplication;
            }
            
            set
            {
                Class1.m_inventorApplication = value;
            }
        }
        public void BeginReformatBomForExcel(ref List<BomRowItem> InventorBomList)
        {
            var grouped = InventorBomList.OrderBy(x => x.BomRowType).GroupBy(x => x.BomRowType);
            MessageBox.Show("InventorBomList.Count= " + InventorBomList.Count);
            int SubAssemblyInt = 1;
            int DetailedPartsInt = 200;
            int COTSContentImportedInt = 500;
            foreach (var group in grouped)
            {
                foreach (BomRowItem item in group)
                {
                    switch (item.BomRowType)
                    {   
                        case 1: //Specifications = no item number
                            item.ItemNo = 0;
                            BomList.Add(item);
                            break;
                        case 2: // Sub assemblies = 1 to 199
                            item.ItemNo = SubAssemblyInt;
                            SubAssemblyInt++;
                            BomList.Add(item);
                            break;
                        case 3: // Detailed Parts = 200 to 500
                            item.ItemNo = DetailedPartsInt;
                            DetailedPartsInt++;
                            BomList.Add(item);
                            break;
                        case 4: // COTS Parts/Content Centre/Imported Components = 500 to 999
                            item.ItemNo = COTSContentImportedInt;
                            COTSContentImportedInt++;
                            BomList.Add(item);
                            break;
                        default:
                            break;
                    }
                }
            }
            BomList.OrderBy(x => x.ItemNo);
            MessageBox.Show("BomList.Count= " + BomList.Count);
            InventorBomList = BomList;
        }
        public void UpdateInventorPartsList(BOMRowsEnumerator oBOMROWs, List<BomRowItem> oSortedPartsList)
{
	MessageBox.Show("Reached UpdateInventorPartsList Sub");
	long i = 0;
	ComponentDefinition oCompdef = default(ComponentDefinition);
	for (i = 1; i <= oBOMROWs.Count; i++) {
		BOMRow oRow = oBOMROWs.Item(i);
		oCompdef = oRow.ComponentDefinitions.Item(1);
		var itemNo = (from BomRowItem a in oSortedPartsList where a.FileName == oCompdef.Document.FullFileName select a.ItemNo);
		MessageBox.Show("New Item number = " + itemNo.ToString());
		MessageBox.Show("Existing Item number: " + oRow.ItemNumber);
	}

}
    }
    public class BomRowItem
    {
        public string FileName { get; set; }
        public string PartNo { get; set; }
        public string Descr { get; set; }
        public string Rev { get; set; }
        public long ItemNo { get; set; }
        public string Material { get; set; }
        public long Qty { get; set; }
        public string Vendor { get; set; }
        public string Comments { get; set; }
        public long BomRowType { get; set; }
    }
}

 which works as designed until I get to the line that reads:

 

BOMRow oRow = oBOMROWs.Item(i)

 

 

whereupon the compiler complains that:

 

"Inventor.BOMRowsEnumerator' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'Inventor.BOMRowsEnumerator' could be found"

 

which is odd because it works in iLogic and vba.

 

Have I missed something stupid or is this a bug?

 

Scratch all that, I'm a dumba$$- if I'd read the vba correctly the section in question should be like this, below:

 

public void UpdateInventorPartsList(BOMRowsEnumerator oBOMROWs, List<BomRowItem> oSortedPartsList)
        {
            MessageBox.Show("Reached UpdateInventorPartsList Sub");
            long i = 0;
            ComponentDefinition oCompdef;

            foreach (BOMRow oRow in oBOMROWs)
            {
                oCompdef = oRow.ComponentDefinitions[1];
                var itemNo = (from BomRowItem a in oSortedPartsList where a.FileName == oCompdef.Document.FullFileName select a.ItemNo);
                MessageBox.Show("New Item number = " + itemNo.ToString());
                MessageBox.Show("Existing Item number: " + oRow.ItemNumber);
            }
        }

Props to this post for letting me see the error of my ways.

 

 

 Ho hum. More caffeine required, stat!

0 Likes
Message 3 of 3

AlexFielder
Advisor
Advisor
Accepted solution

So it seems I have answered my own question; Inventor is quite happy for you to have Bill of Materials items with no item number (circled below):

 

blank BomRowItemNumber.PNG

 

But the thing to remember is to uncheck the "group" option in the parts list should you place a parts list on a drawing.

 

If anyone is interested, I will share the iLogic I created.

0 Likes