Cancel
Showing results for 
Search instead for 
Did you mean: 

Create a line at Minimum distance b/w 2 splines

Creator
Creator

Hi All;

 

I Need to create a line at the point which measures minimum distance between 2 splines;

So i have choose to use measureDistance builder in measureDistanceBuilder1.AnnotationMode = NXOpen.MeasureBuilder.AnnotationType.CreateLine;

 

But how do i get the points to create a line at minimum distance?

 

Any Help!

Thanks FL;

4 REPLIES

Re: Create a line at Minimum distance b/w 2 splines

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

I had a quick look at the documentation for the measureDistanceBuilder object. The point information is probably buried somewhere within its properties, but it sure wasn't obvious where.

 

You could make use of one of the AskMinimumDist functions (UF.Modl. AskMinimumDist, .AskMinimumDist2, or .AskMinimumDist3); these functions readily give up the "point on object" information.

Re: Create a line at Minimum distance b/w 2 splines

Siemens Phenom Siemens Phenom
Siemens Phenom

It's easy using the SNAP ClosestPoints function

 

      Dim s1 = <some spline>
      Dim s2 = <some other spline>

      Dim result As Snap.Compute.DistanceResult = Snap.Compute.ClosestPoints(s1, s2)

      Dim p1 As Position = result.Point1
      Dim p2 As Position = result.Point2

      Snap.Create.Line(p1, p2)

 

Without SNAP, the easiest approach is to use NXOpen.UF.Modl.AskMinimumDist3, as Cowski suggested:

 

      Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession

      Dim workPart As NXOpen.Part = NXOpen.Session.GetSession.Parts.Work

      Dim s1 As NXOpen.Spline = <some spline>
      Dim s2 As NXOpen.Spline = <some other spline>

      Dim opt = 2
      Dim noGuess As Integer = 0
      Dim guessPt As Double() = Nothing
      Dim dist As Double
      Dim p1(2) As double
      Dim p2(2) As Double
      Dim accuracy As Double

      ufs.Modl.AskMinimumDist3(opt, s1.Tag, s2.Tag, noGuess, guessPt, noGuess, guessPt, dist, p1, p2, accuracy)
 
      Dim pt1 As New NXOpen.Point3d(p1(0), p1(1), p1(2))
      Dim pt2 As New NXOpen.Point3d(p2(0), p2(1), p2(2))

      workPart.Curves.CreateLine(pt1, pt2)

 

 

 

山田
yamada

Re: Create a line at Minimum distance b/w 2 splines

Experimenter
Experimenter

Hello Yamada,

If I need to get the point based on a projection vector? I'm using NXopen and NX12.0. Looking forward for your suggestions.

 

Regards,

Raghav

Re: Create a line at Minimum distance b/w 2 splines

Siemens Phenom Siemens Phenom
Siemens Phenom

>  I need to get the point based on a projection vector

 

What point? I thought you were trying to construct a line.

 

What do you mean by "based on"?  Do you mean that you want your line to be parallel to some given vector?  If so, I can't think of any built-in function that will give you this.

山田
yamada