Using Ilogic to number part classes in ranges

Using Ilogic to number part classes in ranges

RainerXGE3N
Contributor Contributor
429 Views
6 Replies
Message 1 of 7

Using Ilogic to number part classes in ranges

RainerXGE3N
Contributor
Contributor

Hi All,

 

Please help with my BOM numbering issue. I have various Part classes that we are manually renumbering. I would like Ilogic to renumber them as follows:

 

Setting: Class 2, Range 2001 - 2999

 

Outcome:

Assembly BOM Item numbers for this class 2001, 2002, 2003, etc.

 

 

Screenshot 2024-11-07 163557.png

0 Likes
Accepted solutions (1)
430 Views
6 Replies
Replies (6)
Message 2 of 7

RainerXGE3N
Contributor
Contributor
Here is my current code that renumbers all same class to 2001, now I need them to ascend.

Dim
oBOM As BOM = ThisAssembly.Document.ComponentDefinition.BOM oBOM.StructuredViewEnabled = True i = 2001 For Each oBOMRow As BOMRow In oBOM.BOMViews.Item("Structured").BOMRows If oBOMRow.ComponentDefinitions(1).Document.PropertySets.Item("Inventor User Defined Properties").Item("Store Type").Value = "STORE PART" Then oBOMRow.ItemNumber = 2001 End If Next
0 Likes
Message 3 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @RainerXGE3N , maybe something like this example.

 

Hope that helps, Curtis

 

Dim oBOM As BOM = ThisAssembly.Document.ComponentDefinition.BOM
Dim oStoreType As Inventor.Property

oBOM.StructuredViewEnabled = True
oBOM.BOMViews("Structured").Sort("Store Type", True)
oBOM.BOMViews("Structured").Renumber(1001, 1)

iSTOREPART = 2000
iSOMETHINGELSE = 3000

For Each oBOMRow As BOMRow In oBOM.BOMViews.Item("Structured").BOMRows

	Dim oDoc As Document = oBOMRow.ComponentDefinitions(1).Document
	Try
		oStoreType = oDoc.PropertySets.Item("Inventor User Defined Properties").Item("Store Type")
	Catch
		Logger.Info("Property not found")
		Continue For
	End Try

	If oStoreType.Value = "STORE PART" Then
		iSTOREPART = iSTOREPART + 1
		oBOMRow.ItemNumber = iSTOREPART
	End If

	If oStoreType.Value = "SOMETHINGELSE" Then
		iSOMETHINGELSE = iSOMETHINGELSE + 1
		oBOMRow.ItemNumber = iSOMETHINGELSE
	End If
Next

oBOM.BOMViews("Structured").Sort("Item", True)

 

Results:

Curtis_Waguespack_1-1730991835427.png

 

 

EESignature

0 Likes
Message 4 of 7

RainerXGE3N
Contributor
Contributor

Thank you Curtis,

 

With a few tweaks to cover all 7 classes this work perfectly.

0 Likes
Message 5 of 7

RainerXGE3N
Contributor
Contributor

Just an important addition:

 

Add a line to sort BOM to part number before renumbering then all classes will be sorted in class and Part numbers:

 

Dim oBOM As BOM = ThisAssembly.Document.ComponentDefinition.BOM
Dim oStoreType As Inventor.Property

oBOM.StructuredViewEnabled = True
oBOM.BOMViews("Structured").Sort("Store Type", True)
oBOM.BOMViews("Structured").Renumber(9001, 1)

iMANPART = 0
iSTOREPART = 2000
iFAST = 4000
iMAT = 5000
iMANASS = 6000
iJIG = 7000
iREF = 8000

oBOM.BOMViews("Structured").Sort("Part Number", True)

For Each oBOMRow As BOMRow In oBOM.BOMViews.Item("Structured").BOMRows

	Dim oDoc As Document = oBOMRow.ComponentDefinitions(1).Document
	Try
		oStoreType = oDoc.PropertySets.Item("Inventor User Defined Properties").Item("Store Type")
	Catch
		Logger.Info("Property not found")
		Continue For
	End Try
	
	If oStoreType.Value = "MANUFACTURED PART" Then
		iMANPART = iMANPART + 1
		oBOMRow.ItemNumber = iMANPART
	End If
	
	If oStoreType.Value = "STORE PART" Then
		iSTOREPART = iSTOREPART + 1
		oBOMRow.ItemNumber = iSTOREPART
	End If

	If oStoreType.Value = "JIG" Then
		iJIG = iJIG + 1
		oBOMRow.ItemNumber = iJIG
	End If	

	If oStoreType.Value = "REF PART" Then
		iREF = iREF + 1
		oBOMRow.ItemNumber = iREF
	End If	
	
Dim oBDoc As Document = oBOMRow.ComponentDefinitions(1).Document
	Try
		oPartType = oBDoc.PropertySets.Item("Inventor User Defined Properties").Item("Part Type")
	Catch
		Logger.Info("Property not found")
		Continue For
	End Try
	
	If oPartType.Value = "FASTENER" Then
		iFAST = iFAST + 1
		oBOMRow.ItemNumber = iFAST
	End If	
	
	If oPartType.Value = "ASSEMBLY" Then
		iMANASS = iMANASS + 1
		oBOMRow.ItemNumber = iMANASS
	End If
	
	If oStoreType.Value = "MATERIAL" Then
		iMAT = iMAT + 1
		oBOMRow.ItemNumber = iMAT
	End If	
		
Next

oBOM.BOMViews("Structured").Sort("Item", True)
0 Likes
Message 6 of 7

RainerXGE3N
Contributor
Contributor

Hi Curtis,

 

I have some virtual parts that is being skipped and renumbered to the 9000 range. How do I also renumber virtual parts?

0 Likes
Message 7 of 7

RainerXGE3N
Contributor
Contributor

Hi,

 

I solved the problem.

 

Thanks,

0 Likes