biw01
Automotive
- Dec 31, 2011
- 152
I am trying to fetch all the bodies from the body collection and then get a face from a particular body inside a part.The way i retrieve the face is by checking its attributes.
My code is as below:
Public Function FnGetFace(ByRef objPart As Part, ByVal faceName As String, ByVal sAttributeType As String) As String
FnGetFace = Nothing
Dim wPart As Part = FnGetNxSession().Parts.Work
For Each body As Body In objPart.Bodies
FnGetNxSession().Parts.SetWork(objPart)
For Each face As Face In body.GetFaces()
'On Error Resume Next
If face.GetAttributeTitlesByType(NXObject.AttributeType.String).Length <> 0 Then
Try
If face.GetStringAttribute(sAttributeType) = faceName Then
'If face.Name = faceName Then
Dim sJournalIdName As String
sJournalIdName = body.JournalIdentifier + "|" + face.JournalIdentifier
FnGetFace = sJournalIdName
SSetWorkPart(wPart)
Exit Function
'End If
End If
Catch ex As Exception
End Try
End If
Next
Next
SSetWorkPart(wPart)
Err.Clear()
End Function
Can someone please point out what i have missed in the code as i am not able to retrieve all the bodies from the part ?
My code is as below:
Public Function FnGetFace(ByRef objPart As Part, ByVal faceName As String, ByVal sAttributeType As String) As String
FnGetFace = Nothing
Dim wPart As Part = FnGetNxSession().Parts.Work
For Each body As Body In objPart.Bodies
FnGetNxSession().Parts.SetWork(objPart)
For Each face As Face In body.GetFaces()
'On Error Resume Next
If face.GetAttributeTitlesByType(NXObject.AttributeType.String).Length <> 0 Then
Try
If face.GetStringAttribute(sAttributeType) = faceName Then
'If face.Name = faceName Then
Dim sJournalIdName As String
sJournalIdName = body.JournalIdentifier + "|" + face.JournalIdentifier
FnGetFace = sJournalIdName
SSetWorkPart(wPart)
Exit Function
'End If
End If
Catch ex As Exception
End Try
End If
Next
Next
SSetWorkPart(wPart)
Err.Clear()
End Function
Can someone please point out what i have missed in the code as i am not able to retrieve all the bodies from the part ?