×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Measure Distance: Visual Basic Journaling (NX 7.5)

Measure Distance: Visual Basic Journaling (NX 7.5)

Measure Distance: Visual Basic Journaling (NX 7.5)

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources