Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate Spline -> Through Points option 4

Status
Not open for further replies.

pratyu

Aerospace
Oct 25, 2012
47
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?
 
John,
I tried executing the grx file. The splines are not joining all the points, they seem to be scattered. I ran the program for 3 dat files, please see the attached image of the output. Also, UG is responding very slowly. Is there any setting that I need to change?
 
 http://files.engineering.com/getfile.aspx?folder=9a2c0ac9-ea59-4589-8957-22fe62d010d0&file=Spline_not_continuous.JPG
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
 
John & BubbaK,
Thanks to you both. Both methods work!! Thanks a lot :)
I restarted my system & grx program worked fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor