Automate Spline -> Through Points option
Automate Spline -> Through Points option
(OP)
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!
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!





RE: Automate Spline -> Through Points option
Best regards,
Michaël.
NX8.5.3 + TC Unified 8.3
Win 7 64 bit
RE: Automate Spline -> Through Points option
I ask because the NX 6 spline command has the capability of creating a spline through points given a .dat file. Creating a journal to mimic this process won't save you much time, if any.
Now if the journal allows you to select a folder full of .dat files and creates a spline for each, that might be useful...
www.nxjournaling.com
RE: Automate Spline -> Through Points option
You're right. I want my journal to select a folder full of .dat files and create a spline for each. I need to automate this.
How can I do it? I have almost 200 .dat files that need to construct splines for.
If it's not much that I am asking for, kindly post VB script addressing the same.
Thanks in advance.
RE: Automate Spline -> Through Points option
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.
RE: Automate Spline -> Through Points option
I don't know how to use GRIP.
The .dat files contain only x, y, z coordinates of points delimited by a tab.
Is it possible to do it with GRIP?
RE: Automate Spline -> Through Points option
To test whether you have a GRIP execute license, download the attached file, change the file extension from .zipper to .zip, extract the files and then go to...
File -> Execute -> Grip...
...run the program 'blob.grx'. If it works you should a get a surface representing an octant of an ellipsoid.
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.
RE: Automate Spline -> Through Points option
But, actually, I think it's easier to use the older spline functions, like NXOpen.UF.Modl.CreateSpline, which is callable from VB, even though it doesn't get recorded. Ask again if you can't figure it out.
If you have Snap, there is Snap.Create.Spline, which is easy to use and nicely documented.
Personally, I wouldn't recommend GRIP unless you're already familiar with it. It could get the job done, but time spent learning GRIP is not a wise investment in your future, IMO.
RE: Automate Spline -> Through Points option
It works. But as others are suggesting, I need a VB program for the same, because this action is a part of a list of actions i am trying to automate.
Bubbak,
Studio Spline doesn't fetch data from .dat files. The option is not there in NX 6.
I am looking for perfectly passing a spline through a given set of points from a .dat file.
RE: Automate Spline -> Through Points option
Can you still provide a few .dat files for testing?
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.
RE: Automate Spline -> Through Points option
Please see the attached. I need the tool to pick all three files (gave you as example), one by one & create splines using "Spline>Through Points" option only.
RE: Automate Spline -> Through Points option
The splines i get from these dat files are almost straight, and yet still they carry 357 ; 394 and 424 segments.
The amount of data used for this shape is at least 100 x too much and will due to the low accuracy in the dat files induce "waviness" in the splines. Using a fit spline on the same points will produce a good curve. These curves are not good for production.
Regards,
Tomas
RE: Automate Spline -> Through Points option
> Studio Spline doesn't fetch data from .dat files.
No, it doesn't. There are two steps: first you read the point data from the file, then you use the point data to create a spline.
These same two steps will be involved no matter what function you call to create the spline.
To get the point data from the file, you have to learn a little bit about the .NET functions for reading text files, like the "ReadAllLines" function. Here is some (untested) code:
CODE --> vb
Option Infer On Imports Snap Public Class MyProgram Public Shared Sub Main() Dim lines As String() = System.IO.File.ReadAllLines("C:\docs\splineData.txt") Dim pts As New List(Of Snap.Position)() For Each line As String In lines Dim coords As String() = line.Split(vbTab) Dim x As Double = System.Double.Parse(coords(0)) Dim y As Double = System.Double.Parse(coords(1)) Dim z As Double = System.Double.Parse(coords(2)) pts.Add(New Position(x,y,z) Next Snap.Create.SplineThroughPoints(pts.ToArray, 3) End Sub End ClassBut this whole exercise is pointless, anyway, because your three sample splines are exactly straight lines.
RE: Automate Spline -> Through Points option
They are just examples since I am obligated not to share the original data.
Don't worry about the shape of the splines, the real problem here is how to automate the task. :)
RE: Automate Spline -> Through Points option
Snap is not there in NX 6
Is there a way to do this in NX 6?
RE: Automate Spline -> Through Points option
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.
RE: Automate Spline -> Through Points option
Please see the files attached. Sorry for the delayed reply.
RE: Automate Spline -> Through Points option
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.
RE: Automate Spline -> Through Points option
> Is there a way to do this in NX 6?
Replace the Snap calls by NX/Open calls. There's only one line of code that's significant, really: call NXOpen.UF.UFCurve.CreateSplineThruPts instead of Snap.Create.SplineThroughPoints. The NX documentation has an example showing how to use NXOpen.UF.UFCurve.CreateSplineThruPts.
RE: Automate Spline -> Through Points option
When you download the file, edit the file extension from '.zipper' to '.zip' before attempting to extract the program files. Note that the source file, 'Spline_from_pts_file.grs', is fully commented so if you're interested you can see what the program does and how it does it.
Anyway, let me know if it worked for you (I did test this using NX 6.0).
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.
RE: Automate Spline -> Through Points option
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?
RE: Automate Spline -> Through Points option
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?
RE: Automate Spline -> Through Points option
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:
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.
RE: Automate Spline -> Through Points option
CODE --> vb
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 SubRE: Automate Spline -> Through Points option
Thanks to you both. Both methods work!! Thanks a lot :)
I restarted my system & grx program worked fine.