Message 1 of 7
Array & Sorting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I just spent about 8 hours combined btw yesterday and today trying to UNDERSTAND vb Arrays and Sorting. But I just can't wrap my mind around the meaning of things. Maybe someone in here can help me understand it?
What I'm trying to do is take some code I got out of the Inventor Help file and adapt it to my needs. I want to compile a list of one iProperty found in all the Parts in one Assembly file, and then sort it alpha-numerically. Then I want to run that list through a Sub that does other things to every file. This is what I have so far:
Option Explicit
Public Sub BOMQuery()
' Set a reference to the assembly document.
' This assumes an assembly document is active.
Dim odoc As AssemblyDocument
Set odoc = ThisApplication.ActiveDocument
' Set a reference to the BOM
Dim oBOM As BOM
Set oBOM = odoc.ComponentDefinition.BOM
' Make sure that the PartsOnly view is enabled.
oBOM.PartsOnlyViewEnabled = True
'Set a reference to the "Parts Only" BOMView
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews.Item("Parts Only")
Debug.Print "Mark"
Debug.Print "----"
'Initialize the tab for ItemNumber
Dim ItemTab As Long
ItemTab = -3
Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab)
End Sub
Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long)
ItemTab = ItemTab + 3
' Iterate through the contents of the BOM Rows.
Dim i As Long
For i = 1 To oBOMRows.count
' Get the current row.
Dim oRow As BOMRow
Set oRow = oBOMRows.Item(i)
'Set a reference to the primary ComponentDefinition of the row
Dim oCompDef As ComponentDefinition
Set oCompDef = oRow.ComponentDefinitions.Item(1)
'Get the file property that contains the "Stock Number"
'The file property is obtained from the parent
'document of the associated ComponentDefinition.
Dim oSN_Value As Property
Set oSN_Value = oCompDef.Document.PropertySets _
.Item("Design Tracking Properties").Item("Stock Number")
Debug.Print Tab(ItemTab); oSN_Value.Value
Next
ItemTab = ItemTab - 3
Call SortMarkList
End Sub
'Below is my n'th attempt at sorting, but I have NO IDEA what I'm doing. It's embarrassing, really!
Private Sub SortMarkList()
Dim oSN_Value As String
OrderBy (oSN_Value)
End Sub
End Sub
I abandoned iLogic for doing this kind of thing b/c it doesn't have any way to look at what's going on. So I'm tentatively doing all this in Inventor VB.
Thanx for the help!
... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator