Selecting an individual assembly component's body

For the past few hours I've been struggling with getting an edge's start and end points, every method that I tried (component.getVerticies, UFEval.Line, UFCurve.Line) returned strange, familiar results. Eventually I realize through an IsOccurrence call that I'm evaluating the incorrect part file.


If I wanted to evaluate the geometry of a particular component, does anyone have any good methods of selecting the correct body / partfile?



The only way I currently know of how to do this is by asking visible objects.


Dim visibleObjects() As DisplayableObject = dispPart.Views.WorkView.AskVisibleObjects()
For Each displayableObject As DisplayableObject In visibleObjects
If TypeOf displayableObject Is Line Then
'process lines
End If
Next

From here I can normally find the type of component that I need and do all the necessary processing. However this is not the most convenient way for me to process my assembly. It would be much easier and faster to process the bodies of these components when I'm running through the assembly recursively using getChildren().



Does anyone know how to do that? Or does anyone have a better method than visible objects?


End Goal: Be able to get an individual component's body that will return "true" on an isOccurrence call by the easiest method for parsing through an entire assembly.


Please let me know if you did not understand the question, it's not the easiest to explain. Thanks.

I'd try using the component object's .FindOccurrence method. Given the component and the prototype body reference, it will return the body occurrence of the component.

Below is a link to some code and example part files (NX 8.5 format). In the block.prt file, the edge that lays on the X axis has been assigned an attribute named "test". Open the find_occs_asm.prt file, the block has been added a few times and repositioned in the assembly file. Run the journal code, it will find the edge of each occurrence, create points on the start and end points of the edge and report the coordinates to the information window.

Find occurrence example

Thank you for the code and description. I appreciate the information. For awhile I getting an exception every time, from your comment "prototype body reference" I was trying to use a body.prototype call! Then I realized you were referring to the part file body reference and it worked perfectly. Thanks

NX 8.5
NX 9.0