Inventor VBA BOM sorting issue with custom order "Array"

Inventor VBA BOM sorting issue with custom order "Array"

soykesa
Explorer Explorer
443 Views
1 Reply
Message 1 of 2

Inventor VBA BOM sorting issue with custom order "Array"

soykesa
Explorer
Explorer

I am using Inventor VBA to sort a Bill of Materials (BOM) based on a custom order defined in my VBA code. I have created an array with the desired order of the BOM items and I am using the oBOMView.Sort method to sort the BOM based on the CS_Description field and the custom order. 

currently, I got an error and am not able to figure out how to solve it.  the below line has "type mismatch" error. 

 Call oBOMView.Sort(Array("CS_Description", "CustomOrder"), Array(True, True), sortOrder)

the rest of the section is below. I am trying to use the array. 

 

Dim oBOM As BOM
Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Structured")
Dim sortOrder(12) As String
    sortOrder(0) = "description 1"
    sortOrder(1) = "description 2"
    sortOrder(2) = "description 3"
    sortOrder(3) = "description 4"
    sortOrder(4) = "description 5"
    sortOrder(5) = "description 6"
    sortOrder(6) = "description 7"
    sortOrder(7) = "description 8"
    sortOrder(8) = "description 9"
    sortOrder(9) = "description 10"
    sortOrder(10) = "description 11"
    sortOrder(11) = "description 12"
    'CS_Description is my custom property.
    Call oBOMView.Sort(Array("CS_Description", "CustomOrder"), Array(True, True), sortOrder)

Call oBOMView.Renumber(1, 1)

 

 

 

 

0 Likes
444 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

In general you need to call BOMView.Sort Method correctly. This method doesn't accept array as argument.

If you can, use iLogic instead of VBA. There is more powerful tools for sorting.

See this previous posts here and  here 

0 Likes