Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Automate Spline -> Through Points option 4

Status
Not open for further replies.

pratyu

Aerospace
Oct 25, 2012
47
0
0
US
Hi all!
P.S: I use NX 6.0.

I see that Record Journal doesn't activate Insert>Curve>"Spline" option for recording.
I have a .dat file in a folder containing x,y,z co ordinates of points. I want to run a journal that allows me to select the .dat files & generates a spline using "ThroughPoints" option only. I insist on ThroughPoints option because the spline passes through all the points instead of just "fitting" into them.
How can I automate it? Please guide!
 
Replies continue below

Recommended for you

BubbaK,
I looked up NX documentation, i added system and open namespaces, added references to the module; yet the code doesn't accept "NXOpen.UF.UFCurve.CreateSplineThruPts". I cannot see ".CreateSplineThruPts" method in UFCurve class. How to add it?
 
Did you test it using the three data files you provided me?

When I ran it using NX 6.0 on my laptop and using the three data files provided, it took less than a second to create the three splines. This is what the results looked like when I did a 'Fit' after the program ran:

Splines_from_Dat_files_using_GRIP_tkdoip.png


John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Digital Factory
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Here's how to call CreateSplineThruPts:

Code:
Shared Sub CreateSplineThroughPoints(qpts As NXOpen.Point3d())

   Dim n As Integer = qpts.Length

   Dim tangentTypes(n-1) As Integer
   Dim curvatureTypes(n-1) As Integer
   Dim tangentVectors(3*n - 1)   As Double
   Dim curvatureVectors(3*n - 1) As Double

   For i As Integer = 0 To n - 1
      tangentTypes(i)   = NXOpen.UF.UFConstants.UF_CURVE_SLOPE_NONE
      curvatureTypes(i) = NXOpen.UF.UFConstants.UF_CURVE_CRVATR_NONE
   Next

   Dim pointData As NXOpen.UF.UFCurve.PtSlopeCrvatr() = New NXOpen.UF.UFCurve.PtSlopeCrvatr(n - 1) {}

   For i As Integer = 0 To n - 1
      pointData(i) = New NXOpen.UF.UFCurve.PtSlopeCrvatr()
      pointData(i).point = New Double(2) {}
      pointData(i).point(0) = qpts(i).X
      pointData(i).point(1) = qpts(i).Y
      pointData(i).point(2) = qpts(i).Z
      pointData(i).slope_type = tangentTypes(i)
      pointData(i).slope = New Double(2) {}
      pointData(i).crvatr_type = curvatureTypes(i)
      pointData(i).crvatr = New Double(2) {}
   Next

   Dim save As Integer = 0    ' Don't save input defining data with the created spline. 
   Dim splineTag As NXOpen.Tag
   Dim parameters As Double() = Nothing
   Dim periodicity As Integer = 0  '  0=non-periodic, 1=periodic

   Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession
   ufs.Curve.CreateSplineThruPts(3, periodicity, n, pointData, parameters, save, splineTag)
   ufs.So.SetVisibilityOption(splineTag, NXOpen.UF.UFSo.VisibilityOption.Visible)

End Sub
 
Status
Not open for further replies.
Back
Top