Four full functions below. Yes, the Next is there for a reason. I also tried Return with no help.
Thanks for your replies thus far.
Public Sub cmdGetProp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetProp.Click
' Define Part Document
' Defined at top
' oApprenticeServerDoc = New InventorApprentice.ApprenticeServerComponent
If Len(txtPartName.Text + "") = 0 Then
MsgBox("Part must be selected!")
cmdBrowse.Focus()
Else
' Try / Catch Logic - is here, but unnecessary since only valid files can be selected from the dialog box
Try
oApprenticeServerDoc = oApprenticeServerApp.Open(txtPartName.Text)
Debug.Write("FILE OPEN!")
Catch ex As Exception
MsgBox("Unable to open the specified file", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation)
Exit Sub
End Try
If oApprenticeServerApp.Document.DocumentType = InventorApprentice.DocumentTypeEnum.kPartDocumentObject Then
' One Part
Q = 1
' Define Inventor Property Objects
GetIVPropObjects()
' Synchronize User-Defined Properties
SynchUserDefProps()
' Populate Data Grid
PopulateDataGrid1_DefineColumns()
PopulateDataGrid1_DefineRows()
ElseIf oApprenticeServerApp.Document.DocumentType = InventorApprentice.DocumentTypeEnum.kAssemblyDocumentObject Then
' Define top level data
' One Part
Q = 1
' Define Inventor Property Objects
GetIVPropObjects()
' Synchronize User-Defined Properties
SynchUserDefProps()
' Populate Data Grid
PopulateDataGrid1_DefineColumns()
PopulateDataGrid1_DefineRows()
' Define nested level data
SUBA = oApprenticeServerDoc.DisplayName
Q = -1
Call GetComponents(oApprenticeServerDoc.ComponentDefinition.Occurrences)
End If
End If
End Sub
Public Sub GetComponents(ByRef CompCollection As InventorApprentice.ComponentOccurrences)
' Define the name of previous component prior to proceeding
Dim prevComp As String
' Interate through the components as InventorApprentice.ComponentOccurrence
For Each xCompOccurrence In CompCollection
Debug.Write("xCompOccurrence.Name: " + xCompOccurrence.Name)
Dim chp As Int16 = xCompOccurrence.Name.IndexOf(":")
Call IsItNumeric(xCompOccurrence.Name.Substring(chp + 1))
If Q > 0 Then
' Define Inventor Property Objects
GetIVAssyPropObjects()
' Synchronize User-Defined Properties
SynchUserDefProps()
' Populate Data Grid
PopulateDataGrid1_DefineRows()
' Delete Last DataGrid Item
Debug.Write("xCompOccurrence.Name.Substring(0, chp - 1): " + xCompOccurrence.Name.Substring(0, chp))
Debug.Write("prevComp: " + prevComp)
If xCompOccurrence.Name.Substring(0, chp) = prevComp Then
PopulateDataGrid1_DeleteRows()
End If
End If
prevComp = xCompOccurrence.Name.Substring(0, chp)
If xCompOccurrence.DefinitionDocumentType = 12291 Then
SUBA = xCompOccurrence.Name
Q = -1
Call GetSubComponents(xCompOccurrence.Definition.Occurrences)
End If
Next
End Sub
Public Sub GetSubComponents(ByRef CompCollection As InventorApprentice.ComponentOccurrences)
' Define the name of previous component prior to proceeding
Dim prevComp As String
' Interate through the components as InventorApprentice.ComponentOccurrence
For Each xCompOccurrence In CompCollection
Debug.Write("xCompOccurrence.Name: " + xCompOccurrence.Name)
Dim chp As Int16 = xCompOccurrence.Name.IndexOf(":")
Call IsItNumeric(xCompOccurrence.Name.Substring(chp + 1))
If Q > 0 Then
' Define Inventor Property Objects
GetIVAssyPropObjects()
' Synchronize User-Defined Properties
SynchUserDefProps()
' Populate Data Grid
PopulateDataGrid1_DefineRows()
' Delete Last DataGrid Item
Debug.Write("xCompOccurrence.Name.Substring(0, chp - 1): " + xCompOccurrence.Name.Substring(0, chp))
Debug.Write("prevComp: " + prevComp)
If xCompOccurrence.Name.Substring(0, chp) = prevComp Then
PopulateDataGrid1_DeleteRows()
End If
End If
prevComp = xCompOccurrence.Name.Substring(0, chp)
Next
Return
End Sub
Public Sub IsItNumeric(ByVal ConStr As String)
' Example Data is 12XXX or 12
Q = CInt(ConStr.Replace("X", ""))
Debug.Write("Q: " + Str(Q))
End Sub