Sort BOM by custom parameter

Sort BOM by custom parameter

Damian_Apex
Enthusiast Enthusiast
581 Views
2 Replies
Message 1 of 3

Sort BOM by custom parameter

Damian_Apex
Enthusiast
Enthusiast

I want to sort the BOM by "Description" and a custom parameter "LENGTH", my problem is that I have to add the parameter "LENGTH" manually every time, if I do not add it I get an error
"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
I would prefer if iLogick did it automatically so I don't have to remember about it.

 

 

Public Sub Main()

Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

Dim oAssyCompDef As AssemblyComponentDefinition
oAssyCompDef = oAssyDoc.ComponentDefinition

Dim oBOM As BOM
oBOM = oAssyCompDef.BOM

oBOM.StructuredViewEnabled = True

Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Structured")
Trace.WriteLine("oBOM.BOMViews.Item(Structured)")
oBOM.StructuredViewFirstLevelOnly = False

Try 
	oBOMView.Sort("Description", True, "LENGTH", True)
	oBOMView.Renumber(1, 1)
Catch
	MessageBox.Show("The program has failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	MessageBox.Show("ADD PARAMETER TO BOM:" & vbCrLf  & "GO TO 'Bill of material' > Open Tab 'Structured' > 'Add Custom iProperty Columns' > add parameter with name 'LENGTH' ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	Exit Sub
End Try
End Sub

 

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

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Damian_Apex 

Unfortunately I don't think you can add columns to a BOM via API. You can however import a BOM customization:

Dim oBOM As BOM = ThisDoc.Document.ComponentDefinition.BOM
oBOM.ImportBOMCustomization("C:\Users\jhoel\Documents\BOMtest.xml")

Add the column to a BOM and hit export. Then import the created xml-file with the code above.

Message 3 of 3

Damian_Apex
Enthusiast
Enthusiast

perfect that's exactly what I need

0 Likes