- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
How do I sort the array in this code correctly from 1 - 9999.
Sub Main() ' You have to run this in a drawing with a assembly on the first page. Dim oDrawingDoc As Document Dim oDocs As Documents Dim oSheets As IManagedSheets Dim oGASheet As IManagedSheet Dim oGAView As DrawingView Dim oGASheet1 As Sheet Dim oViewModelDoc As Document Dim oPartsArray As New List(Of String) oDrawingDoc = ThisApplication.ActiveDocument oDocs = ThisApplication.Documents oSheets = ThisDrawing.Sheets oGASheet = oSheets.ItemByName("A GA:1") oGASheet1 = oDrawingDoc.Sheets(1) oGAView = oGASheet1.DrawingViews(1) oViewModelDoc = oGASheet.View(oGAView.Name).ModelDocument oDef = oViewModelDoc.ComponentDefinition oBOM = oDef.BOM Dim oBOMView As BOMView = oBOM.BOMViews(2) For Each oRow As BOMRow In oBOMView.BOMRows For Each rDef As ComponentDefinition In oRow.ComponentDefinitions oPartsArray.Add(oRow.ItemNumber.ToString()) oPartsArray.Sort Next Next For j As Integer = 0 To oPartsArray.Count - 1 If j = 0 Then oText = oPartsArray(j) Else oText = oText & ", " & oPartsArray(j) End If Next MessageBox.Show(oText, "List of items in Array") Logger.Info(oText) End Sub
Here is the code and below shows the outcome:
INFO|List of items in Array
INFO|01, 02, 03, 04, 05, 06, 07, 08, 104, 106, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 2001, 2002, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 6001, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 9004, 91, 93, 94, 95, 99
Thank you in advanced.
Solved! Go to Solution.