Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a function from a function

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
I have a function like this:

GetPartProperties

.
.
.

Call GetComponents(oApprenticeServerDoc.ComponentDefinition.Occurrences)

Public Sub GetComponents(ByRef CompCollection As InventorApprentice.ComponentOccurrences)

' Interate through the components as InventorApprentice.ComponentOccurrence
For Each xCompOccurrence In CompCollection

.
.
.

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)

.
.
.

Next

End Sub


GetPartProps goes to the function GetComponents. If the component is another assembly, then it is supposed to run GetSubComponents. All this works, except that after GetSubComponents is run, it never goes back to GetComponents to get the next one.

Any thoughts, and thanks for the help!
 
Is the "Next" in GetSubComponents there for a reason? Because it won't match up with the ForEach in the GetComponents method.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top