Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Measure Distance: Visual Basic Journaling (NX 7.5)

Status
Not open for further replies.

neoleachster

Automotive
Apr 20, 2012
5
Good afternoon fellow eng-tips users,

I have created a script in Visual Basic which loops through and measures the minimum distance between each solid body and every other solid body in my session. The problem is, that the measurement sometimes fails... When it does I get a result of 0mm, rather than the script falling over. To be a bit more clear, I mean that it gives a distance of 0mm although there is a clear gap between the bodies.

Does anyone know how to catch an error with the measure distance command, or what might be causing it in the CAD so that I can prevent it in future.

The relevant section of my script is:

'*******************************************************************

For Each body1 As Body In theSession.Parts.Work.Bodies

For Each body2 As Body In theSession.Parts.Work.Bodies

If Not body1.Name = body2.Name Then

Dim unit1 As Unit = Nothing

Dim measureDistance1 As MeasureDistance

measureDistance1 = workPart.MeasureManager.NewDistance(unit1, MeasureManager.MeasureType.Minimum, body1, body2)

Console.WriteLine("Distance from " & body1.Name & " to " & body2.Name & " = " & measureDistance1.Value.ToString)

End If

Next

Next

'*******************************************************************

As a side note, when I try this manually on the bodies that fail, I get an error window saying the following:

"Measurement failed. Modeler error: failed to find closest approach."

Also, when I turn off the "Always Exact" option in the measurement dialog box it works, but I'm not sure how to do this from the journal side.

Any help or thoughts would be appreciated.

Neoleachster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor