Curve direction

Hi Everybody,
does anyone know if it is possible to change the direction of a curve
with a journal? An example would be great!
Thanks!

For what reason do you need to reverse the curve?
I ask because some functions that require a direction input allow you to use Sense.Forward or Sense.Reverse without the need to actually reverse the curve.

Hi, thanks for your answer!
In my journal, I want to select some intersection curves for further operations.
Maybe to create a variable offset curve from the intersection curve. I have the problem, that
sometimes the direction of the intersection curves are different and the offset begins
at the wrong end of the intersection curve. I thought about to change the curve direction with
the help of the cursor point location in the selection function. Unfortunately it didn't worked..

Can you post a short code sample that illustrates your problem?

Attached is my code example, sorry it isn't so short..
In this Example I select a Face and a Spline on the face. The program
creates a line normal to the surface at 1, 2,..100% on spline position.
With the lines, offset points will be created and be used for the creation
of a new spline. The program works very well, the only problem is that
if the curve on the face has a wrong direction, the offset starts at the wrong end.
I tried to change the curve direction with the code, but there was no solution..
Hope you can understand it :-)
Thanks

Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.Features
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports System.Maths
Imports System.Windows.Forms

Module NXJournal
Public ufs As UFSession = UFSession.GetUFSession()
Public theUI As UI = ui.GetUI
Public theSession As Session = Session.GetSession()
Public workPart As Part = theSession.Parts.Work
Public displayPart As Part = theSession.Parts.Display
Public markId1, markId2 As Session.UndoMarkId
'---------------------
Public title as String
Public selobj As NXObject
Public cursor As Point3d
'---------------------
Public spline1, spline2 As Spline
Public face1 As Face
Public Line1 as Line
Public i, j, k as Integer
Public n, perc as Double
Public point1, point2 as Point
Public point3 As Point3D
Public dist As Double = 10
Public offset(100) As Point

Sub Main
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

'Selection Block
title="Select Spline"
If select_spline(selobj) = Selection.Response.Ok
spline1 = selobj
Else
Exit Sub
End If
title="Select Face"
If select_face(selobj) = Selection.Response.Ok
face1 = selobj
Else
Exit Sub
End If

For i=0 to 100
n = i/100
'Creation of 100 points along the spline
Dim scalar1 As Scalar = Nothing
scalar1 = workPart.Scalars.CreateScalar(n, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
point1 = workPart.Points.CreatePoint(spline1, scalar1, SmartObject.UpdateOption.WithinModeling)
'Creation of a Line normal to the surface at Each point with the length of dist
Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing
Dim associativeLineBuilder1 As Features.AssociativeLineBuilder
associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)
associativeLineBuilder1.Associative = True
Dim nullXform As Xform = Nothing
point2 = workPart.Points.CreatePoint(point1, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeLineBuilder1.StartPoint.Value = point2
associativeLineBuilder1.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point
associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Normal
associativeLineBuilder1.Limits.StartLimit.Distance.RightHandSide = "0"
associativeLineBuilder1.Limits.EndLimit.LimitOption = GeometricUtilities.CurveExtendData.LimitOptions.Value
associativeLineBuilder1.EndNormal.Value = face1
associativeLineBuilder1.Limits.EndLimit.Distance.RightHandSide = dist
Dim nullView As NxOpen.View = Nothing
point3 = point1.coordinates
associativeLineBuilder1.EndNormal.SetValue(face1, nullView, point3)
Dim myLineFeature As Features.AssociativeLine
myLineFeature = associativeLineBuilder1.Commit()
associativeLineBuilder1.Destroy()
Dim myEntities() As NXObject
myEntities = myLineFeature.GetEntities()
Line1 = myEntities(0)
'Offset value Calculation [%] (Example f(i)=sin(i))
perc=Math.Sin(i/10)
'Point at the offset
Dim scalar2 As Scalar
scalar2 = workPart.Scalars.CreateScalar(perc, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
offset(i) = workPart.Points.CreatePoint(Line1, scalar2, SmartObject.UpdateOption.WithinModeling)
scalar2 = Nothing
'Deleting the line
Dim objects1(0) As NXObject
objects1(0) = Line1
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)
Next i

Dim partCleanup1 As PartCleanup
PartCleanup1 = theSession.NewPartCleanup()
partCleanup1.TurnOffHighlighting = True
partCleanup1.DoCleanup()
theSession.deleteUndoMark(markId2, "Part Cleanup")

'Create the spline
call create_spline(i-1)

End Sub

Sub create_spline(ByVal j as Integer)
Dim studioSplineBuilder1 As Features.StudioSplineBuilder
Dim nullFeatures_StudioSpline As Features.StudioSpline = Nothing
studioSplineBuilder1 = workPart.Features.CreateStudioSplineBuilder(nullFeatures_StudioSpline)
studioSplineBuilder1.InputCurveOption = Features.StudioSplineBuilder.CurveOption.Retain
studioSplineBuilder1.SplineMethod = Features.StudioSplineBuilder.Method.ThroughPoints
studioSplineBuilder1.Degree = 3
studioSplineBuilder1.IsPeriodic = False
studioSplineBuilder1.MatchKnots = Features.StudioSplineBuilder.MatchKnotsType.None
Dim knots1(-1) As Double
studioSplineBuilder1.SetKnots(knots1)
Dim parameters1(-1) As Double
studioSplineBuilder1.SetParameters(parameters1)
'Point 1 to j
Dim geometricConstraintData(j) As Features.GeometricConstraintData
Dim constraints1(j) As Features.GeometricConstraintData
Dim nullDirection As Direction = Nothing
Dim nullScalar As Scalar = Nothing
Dim nullOffset As Offset = Nothing
For k = 0 to j
geometricConstraintData(k) = studioSplineBuilder1.ConstraintManager.CreateGeometricConstraintData()
geometricConstraintData(k).Point = Offset(k)
geometricConstraintData(k).AutomaticConstraintDirection = Features.GeometricConstraintData.ParameterDirection.Iso
geometricConstraintData(k).AutomaticConstraintType = Features.GeometricConstraintData.AutoConstraintType.None
geometricConstraintData(k).TangentDirection = nullDirection
geometricConstraintData(k).TangentMagnitude = nullScalar
geometricConstraintData(k).Curvature = nullOffset
geometricConstraintData(k).CurvatureDerivative = nullOffset
geometricConstraintData(k).HasSymmetricModelingConstraint = False
constraints1(k) = geometricConstraintData(k)
Next k
studioSplineBuilder1.ConstraintManager.SetContents(constraints1)
Dim feature1 As Features.Feature
feature1 = studioSplineBuilder1.CommitFeature()
spline2 = studioSplineBuilder1.Curve
studioSplineBuilder1.Destroy()
End Sub

Function select_spline(ByRef selobj As NXObject) As Selection.Response
Dim theUI As UI = ui.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.Curves}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
"Select a spline", title, _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function

Function select_face(ByRef selobj As NXObject) As Selection.Response
Dim theUI As UI = ui.GetUI
'Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.Faces}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
"Select a Face", title, _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Application.Exit()
End If
End Function

End Module

Here is one potential work-around:


Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.Features
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports System.Math
Imports System.Windows.Forms

Module NXJournal
Public ufs As UFSession = UFSession.GetUFSession()
Public theUI As UI = ui.GetUI
Public theSession As Session = Session.GetSession()
Public workPart As Part = theSession.Parts.Work
Public displayPart As Part = theSession.Parts.Display
Public markId1, markId2 As Session.UndoMarkId
'---------------------
Public title As String
Public selobj As NXObject
Public cursor As Point3d
'---------------------
Public spline1, spline2 As Spline
Public face1 As Face
Public Line1 As Line
Public n, perc As Double
Public point1, point2 As Point
Public point3 As Point3D
Public dist As Double = 10
Public offset(100) As Point

Sub Main()
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

'Selection Block
title = "Select Spline"
If select_spline(selobj) = Selection.Response.Ok Then
spline1 = selobj
Else
Exit Sub
End If
title = "Select Face"
If select_face(selobj) = Selection.Response.Ok Then
face1 = selobj
Else
Exit Sub
End If

'&&&&& added code &&&&&
Dim reverse As Boolean = False
Dim splineStartPt(2) As Double
Dim viewTag As Tag = Tag.Null
ufs.Modl.EvaluateCurve(spline1.Tag, 0, UFConstants.UF_MODL_LOC, splineStartPt)
ufs.Disp.DisplayTemporaryPoint(viewTag, UFDisp.ViewType.UseWorkView, splineStartPt, Nothing, UFDisp.PolyMarker.Asterisk)
Dim response As Integer
response = theUI.NXMessageBox.Show("Direction", NXMessageBox.DialogType.Question, "Spline start position shown, start from this end?")
'1 = Yes
'2 = No
If response = 1 Then
reverse = False
Else
reverse = True
End If
'&&&&&&&&&&&&&&&&&&&&&&&&

Dim i As Integer
For i = 0 To 100
n = i / 100
'&&&&& added code &&&&&
If reverse Then
n = 1 - n
End If
'&&&&&&&&&&&&&&&&&&&&&&
'Creation of 100 points along the spline
Dim scalar1 As Scalar = Nothing
scalar1 = workPart.Scalars.CreateScalar(n, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
point1 = workPart.Points.CreatePoint(spline1, scalar1, SmartObject.UpdateOption.WithinModeling)
'Creation of a Line normal to the surface at Each point with the length of dist
Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing
Dim associativeLineBuilder1 As Features.AssociativeLineBuilder
associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)
associativeLineBuilder1.Associative = True
Dim nullXform As Xform = Nothing
point2 = workPart.Points.CreatePoint(point1, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeLineBuilder1.StartPoint.Value = point2
associativeLineBuilder1.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point
associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Normal
associativeLineBuilder1.Limits.StartLimit.Distance.RightHandSide = "0"
associativeLineBuilder1.Limits.EndLimit.LimitOption = GeometricUtilities.CurveExtendData.LimitOptions.Value
associativeLineBuilder1.EndNormal.Value = face1
associativeLineBuilder1.Limits.EndLimit.Distance.RightHandSide = dist
Dim nullView As NxOpen.View = Nothing
point3 = point1.coordinates
associativeLineBuilder1.EndNormal.SetValue(face1, nullView, point3)
Dim myLineFeature As Features.AssociativeLine
myLineFeature = associativeLineBuilder1.Commit()
associativeLineBuilder1.Destroy()
Dim myEntities() As NXObject
myEntities = myLineFeature.GetEntities()
Line1 = myEntities(0)
'Offset value Calculation [%] (Example f(i)=sin(i))
perc = Math.Sin(i / 10)
'Point at the offset
Dim scalar2 As Scalar
scalar2 = workPart.Scalars.CreateScalar(perc, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
offset(i) = workPart.Points.CreatePoint(Line1, scalar2, SmartObject.UpdateOption.WithinModeling)
scalar2 = Nothing
'Deleting the line
Dim objects1(0) As NXObject
objects1(0) = Line1
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)
Next i

Dim partCleanup1 As PartCleanup
PartCleanup1 = theSession.NewPartCleanup()
partCleanup1.TurnOffHighlighting = True
partCleanup1.DoCleanup()
theSession.deleteUndoMark(markId2, "Part Cleanup")

'Create the spline
Call create_spline(i - 1)

End Sub

Sub create_spline(ByVal j As Integer)
Dim studioSplineBuilder1 As Features.StudioSplineBuilder
Dim nullFeatures_StudioSpline As Features.StudioSpline = Nothing
studioSplineBuilder1 = workPart.Features.CreateStudioSplineBuilder(nullFeatures_StudioSpline)
studioSplineBuilder1.InputCurveOption = Features.StudioSplineBuilder.CurveOption.Retain
studioSplineBuilder1.SplineMethod = Features.StudioSplineBuilder.Method.ThroughPoints
studioSplineBuilder1.Degree = 3
studioSplineBuilder1.IsPeriodic = False
studioSplineBuilder1.MatchKnots = Features.StudioSplineBuilder.MatchKnotsType.None
Dim knots1(-1) As Double
studioSplineBuilder1.SetKnots(knots1)
Dim parameters1(-1) As Double
studioSplineBuilder1.SetParameters(parameters1)
'Point 1 to j
Dim geometricConstraintData(j) As Features.GeometricConstraintData
Dim constraints1(j) As Features.GeometricConstraintData
Dim nullDirection As Direction = Nothing
Dim nullScalar As Scalar = Nothing
Dim nullOffset As Offset = Nothing
For k As Integer = 0 To j
geometricConstraintData(k) = studioSplineBuilder1.ConstraintManager.CreateGeometricConstraintData()
geometricConstraintData(k).Point = offset(k)
geometricConstraintData(k).AutomaticConstraintDirection = Features.GeometricConstraintData.ParameterDirection.Iso
geometricConstraintData(k).AutomaticConstraintType = Features.GeometricConstraintData.AutoConstraintType.None
geometricConstraintData(k).TangentDirection = nullDirection
geometricConstraintData(k).TangentMagnitude = nullScalar
geometricConstraintData(k).Curvature = nullOffset
geometricConstraintData(k).CurvatureDerivative = nullOffset
geometricConstraintData(k).HasSymmetricModelingConstraint = False
constraints1(k) = geometricConstraintData(k)
Next k
studioSplineBuilder1.ConstraintManager.SetContents(constraints1)
Dim feature1 As Features.Feature
feature1 = studioSplineBuilder1.CommitFeature()
spline2 = studioSplineBuilder1.Curve
studioSplineBuilder1.Destroy()
End Sub

Function select_spline(ByRef selobj As NXObject) As Selection.Response
Dim theUI As UI = ui.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.Curves}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
"Select a spline", title, _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function

Function select_face(ByRef selobj As NXObject) As Selection.Response
Dim theUI As UI = ui.GetUI
'Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.Faces}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
"Select a Face", title, _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Application.Exit()
End If
End Function

End Module

First of all, thank you very much for this idea.
This is a good way how to make sure that the start of the offset
is on the correct side. I can go ahead with this. The very best solution would be
if the user of the program does not need to decide wheter to change the direction,
or not. As I understand your solution, there is no function to really change the direction
of the curve, or? Maybe an API function? My Idea was that my code will change the direction
dependent on where the user is clicking on the curve.
Thanks again!

If you'd like to base the start point on the user selection, you have everything you need to do that. The .SelectObject method returns the point the user picked (the cursor variable). You can check if the start or end point of the spline is closer to the pick point and combine it with the code above, eliminating the dialog box.

This is what I've tried to do. Unfortunately the cursor point location is not directly
touching the selected object (I don't know why..), I realized that it's in the view
direction but somewhere in depth. If you try to make the cursor point location visible
you will see it (or I did something wrong..:-)). So I can't use it for a comparison of the distance.
Regarding the curve direction: do you know another method to change the direction (API?)?
Many thanks!

You can draw a line along the view direction through the pick point and measure to the line. There is an example in the GTAC solution center, select point on curve (document ID: nx_api4409, by Steve Labout), that uses this technique.

The code below will prompt you to select a curve, in the information window it will write the coordinates of the point on the curve near the pick point and the curve parameter for the point on the curve. If the parameter is near zero, the curve was picked near the start point; if the parameter is near one, the curve was picked near the end point.

The code in Sub Main was written by me, the rest of the subs and functions (i.e. the hard stuff) were taken (nearly verbatim) from the GTAC example mentioned above.


Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()

Sub Main()

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim myCurve As Curve
Dim curveTag As Tag

Dim pt(2) As Double

Do

curveTag = select_point_on_curve("select a curve", pt)
If curveTag = Tag.Null Then Exit Do
myCurve = Utilities.NXObjectManager.Get(curveTag)

lw.WriteLine("point on curve near pick point")
lw.WriteLine("X = " & pt(0).ToString)
lw.WriteLine("Y = " & pt(1).ToString)
lw.WriteLine("Z = " & pt(2).ToString)
lw.WriteLine("")

'was curve selected near start or end point?
Dim curveEvaluator As System.IntPtr
ufs.Eval.Initialize(myCurve.Tag, curveEvaluator)
Dim parm As Double
Dim closestPoint(2) As Double
ufs.Eval.EvaluateClosestPoint(curveEvaluator, pt, parm, closestPoint)

lw.WriteLine("curve parameter near pick point (0 = start, 1 = end)")
lw.WriteLine("parameter: " & parm.ToString)
lw.WriteLine("")

Loop

lw.Close()

End Sub

'code below taken from GTAC example: select point on curve

Public Sub map_view2abs(ByRef c() As Double)

Dim vname As String = ""
Dim abs_mx() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
Dim vw() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Dim mx() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Dim irc As Integer = 0
ufs.Ui.AskLastPickedView(vname)
Dim wp As Part = theSession.Parts.Work
Dim lastViewPicked As View = CType(wp.ModelingViews.FindObject(vname), ModelingView)

Dim vmx As Matrix3x3 = lastViewPicked.Matrix()
vw(3) = vmx.Xx
vw(4) = vmx.Xy
vw(5) = vmx.Xz
vw(6) = vmx.Yx
vw(7) = vmx.Yy
vw(8) = vmx.Yz
vw(9) = vmx.Zx
vw(10) = vmx.Zy
vw(11) = vmx.Zz

ufs.Trns.CreateCsysMappingMatrix(vw, abs_mx, mx, irc)
ufs.Trns.MapPosition(c, mx)

End Sub

Public Sub map_abs2view(ByRef c() As Double)

Dim vname As String = ""
Dim abs_mx() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
Dim vw() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Dim mx() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Dim irc As Integer = 0
ufs.Ui.AskLastPickedView(vname)
Dim wp As Part = theSession.Parts.Work
Dim lastViewPicked As View = _
CType(wp.ModelingViews.FindObject(vname), ModelingView)

Dim vmx As Matrix3x3 = lastViewPicked.Matrix()
vw(3) = vmx.Xx
vw(4) = vmx.Xy
vw(5) = vmx.Xz
vw(6) = vmx.Yx
vw(7) = vmx.Yy
vw(8) = vmx.Yz
vw(9) = vmx.Zx
vw(10) = vmx.Zy
vw(11) = vmx.Zz

ufs.Trns.CreateCsysMappingMatrix(abs_mx, vw, mx, irc)
ufs.Trns.MapPosition(c, mx)

End Sub

Public Sub ask_pos_on_obj(ByVal obj As NXOpen.Tag, ByVal loc() As Double)
Dim aLine As NXOpen.Tag = NXOpen.Tag.Null
Dim cp() As Double = {0, 0, 0}
Dim dist As Double = 0
Dim lp As UFCurve.Line
Dim sp(2) As Double
Dim ep(2) As Double
lp.start_point = sp
lp.end_point = ep

map_abs2view(loc)

lp.start_point(0) = loc(0)
lp.start_point(1) = loc(1)
lp.start_point(2) = loc(2) + 10000
lp.end_point(0) = loc(0)
lp.end_point(1) = loc(1)
lp.end_point(2) = loc(2) - 10000

map_view2abs(lp.start_point)
map_view2abs(lp.end_point)

ufs.Curve.CreateLine(lp, aLine)
ufs.Modl.AskMinimumDist(obj, aLine, 0, cp, 0, cp, dist, loc, cp)
ufs.Obj.DeleteObject(aLine)

End Sub

Public Sub display_temporary_asterisk(ByVal coords() As Double)
Dim attrib As UFObj.DispProps
attrib.blank_status = 1
attrib.color = 186
attrib.line_width = UFConstants.UF_OBJ_WIDTH_NORMAL
ufs.Disp.DisplayTemporaryPoint(NXOpen.Tag.Null, _
UFDisp.ViewType.UseActivePlus, coords, attrib, _
UFDisp.PolyMarker.Asterisk)

End Sub

Public Function mask_for_curves(ByVal select_ As IntPtr, ByVal userdata As IntPtr) As Integer

Dim num_triples As Integer = 4
Dim mask_triples(3) As UFUi.Mask

mask_triples(0).object_type = UFConstants.UF_line_type
mask_triples(0).object_subtype = 0
mask_triples(0).solid_type = 0

mask_triples(1).object_type = UFConstants.UF_circle_type
mask_triples(1).object_subtype = 0
mask_triples(1).solid_type = 0

mask_triples(2).object_type = UFConstants.UF_conic_type
mask_triples(2).object_subtype = 0
mask_triples(2).solid_type = 0

mask_triples(3).object_type = UFConstants.UF_spline_type
mask_triples(3).object_subtype = 0
mask_triples(3).solid_type = 0

ufs.Ui.SetSelMask(select_, _
UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
num_triples, mask_triples)

Return UFConstants.UF_UI_SEL_SUCCESS

End Function

Public Function select_point_on_curve(ByVal prompt As String, _
ByRef cp() As Double) As NXOpen.Tag
Dim resp As Integer = 0
Dim thing As NXOpen.Tag = NXOpen.Tag.Null
Dim theView As NXOpen.Tag = NXOpen.Tag.Null
Dim mask_crvs As UFUi.SelInitFnT = AddressOf mask_for_curves

ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

ufs.Ui.SelectWithSingleDialog("Select_a_curve", prompt, _
UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, _
mask_crvs, Nothing, resp, thing, cp, theView)

ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

If resp = UFConstants.UF_UI_OBJECT_SELECTED Or _
resp = UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then

ask_pos_on_obj(thing, cp)
display_temporary_asterisk(cp)
ufs.Disp.SetHighlight(thing, 0)
Return thing

End If

Return Tag.Null

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module

I don't know if there is an API function to reverse the direction of a curve. I have not run across one in my programming adventures, but I would not be surprised to learn that one did exist.

Thank you very much!
This is what I was looking for :-)

As far as I know, there is no convenient API to reverse curve direction. But it's pretty easy to do for most curves:
(1) Lines: swap start and end point
(2) Arcs: fiddle with coordinate system and angles
(3) Splines: reverse order of poles

Dear ciao,
thanks for your comment. Acc. to (3): How can I reverse the order of poles?