EngProgrammer
Aerospace
Ive created a function that creates a spline based on subject.
I can't get the spline to appear in the cad window. What am i missing?
I can't get the spline to appear in the cad window. What am i missing?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function makeSpline(ByVal points As ArrayList) As Spline
Dim ufs As UF.UFSession = UF.UFSession.GetUFSession
Dim mytag As Tag
Dim mySpline As Spline = Nothing
Dim degree As Integer = 3
Dim periodicity As Integer = 0
Dim numPoints As Integer = points.Count
Dim pts As New ArrayList
Dim pt(2) As Double
For Each iPoint As Point3d In points
pt(0) = iPoint.X
pt(1) = iPoint.Y
pt(2) = iPoint.Z
Console.WriteLine("Point(" & pt(0).ToString() & "," & pt(1).ToString() & "," & pt(2).ToString() & ")")
pts.Add(pt)
Next
Dim ptData(pts.Count - 1) As NXOpen.UF.UFCurve.PtSlopeCrvatr
For i As Integer = 0 To pts.Count - 1
ptData(i).point = pts(i)
ptData(i).slope_type = UF.UFConstants.UF_CURVE_SLOPE_AUTO
ptData(i).crvatr_type = UF.UFConstants.UF_CURVE_CRVATR_NONE
Next
' ufs.Curve.CreateSplineThruPts(degree, periodicity, numPoints, ptData, _
' user specified parameterization of input points: use 'nothing' for
' default parameterization, save defining data? 1 = yes (anything else =no)
' return tag variable of new spline
ufs.Curve.CreateSplineThruPts(degree, periodicity, numPoints, ptData, Nothing, 0, mytag)
' Convert Tag Reference to NXOpen Object
mySpline = Utilities.NXObjectManager.Get(mytag)
mySpline.SetVisibility(SmartObject.VisibilityOption.Visible)
mySpline.RedisplayObject()
MsgBox("Length of Spline = " & mySpline.GetLength)
Return mySpline
End Function
For i As Integer = 0 To pts.Count - 1
[highlight #FCE94F]ptData(i).point = pts(i)[/highlight]
ptData(i).slope_type = UF.UFConstants.UF_CURVE_SLOPE_AUTO
ptData(i).crvatr_type = UF.UFConstants.UF_CURVE_CRVATR_NONE
Next
Public Function makeSpline(ByVal points As System.Collections.ArrayList) As Spline
Dim ufs As UFSession = UFSession.GetUFSession
Dim mytag As Tag
Dim mySpline As Spline = Nothing
Dim degree As Integer = 3
Dim periodicity As Integer = 0
Dim numPoints As Integer = points.Count
Dim ptData(points.Count - 1) As NXOpen.UF.UFCurve.PtSlopeCrvatr
For i As Integer = 0 To points.Count - 1
Dim pt(2) As Double
pt(0) = points.Item(i).X
pt(1) = points.Item(i).Y
pt(2) = points.Item(i).Z
ptData(i).point = pt
ptData(i).slope_type = UFConstants.UF_CURVE_SLOPE_AUTO
ptData(i).crvatr_type = UFConstants.UF_CURVE_CRVATR_NONE
Next
' ufs.Curve.CreateSplineThruPts(degree, periodicity, numPoints, ptData, _
' user specified parameterization of input points: use 'nothing' for
' default parameterization, save defining data? 1 = yes (anything else =no)
' return tag variable of new spline
ufs.Curve.CreateSplineThruPts(degree, periodicity, numPoints, ptData, Nothing, 0, mytag)
' Convert Tag Reference to NXOpen Object
mySpline = Utilities.NXObjectManager.Get(mytag)
MsgBox("Length of Spline = " & mySpline.GetLength)
Return mySpline
End Function
For Each iPoint As Point3d In points
pt(0) = iPoint.X
pt(1) = iPoint.Y
pt(2) = iPoint.Z
Console.WriteLine("Point(" & pt(0).ToString() & "," & pt(1).ToString() & "," & pt(2).ToString() & ")")
pts.Add(pt)
Next
'the following results might surprise you
For Each jpoint As Double() In pts
lw.WriteLine(jpoint(0) & ", " & jpoint(1) & ", " & jpoint(2))
Next
For Each iPoint As Point3d In points
Dim pt(2) As Double
pt(0) = iPoint.X
pt(1) = iPoint.Y
pt(2) = iPoint.Z
pts.Add(pt)
Next