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

I think you need to convert your dat file to an expressions file. Then inset curve and choose point location by expression, point it to the expressions file and hit enter...

Best regards,

Michaël.

NX8.5.3 + TC Unified 8.3
Win 7 64 bit



 
How many of these splines do you have to create?
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
 
Cowski,
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.
 
Can you execute GRIP programs? Is so, could you provide a few of your .dat files so as to see how your data is formatted?

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.
 
John,
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?
 
Yes, I could write a simple GRIP program to do just that.

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.
 
 http://files.engineering.com/getfile.aspx?folder=10f940d4-cba7-48ba-95fa-aaf0756cfbe6&file=blob.zipper
Try recording Insert-->Curve-->Studio Spline, instead. That does have journal support.

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.
 
John,
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.
 
You can call GRIP programs from other programs include Journals.

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.
 
By curiosity, i hope that these dat files are examples and not something that you will use in a real model. ?
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
 
> Bubbak,
> 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:
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 Class

But this whole exercise is pointless, anyway, because your three sample splines are exactly straight lines.
 
Toost,
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. :)
 
BubbaK,
Snap is not there in NX 6 :-(
Is there a way to do this in NX 6?
 
Could you edit the files so that all fields have the same number of characters? In other words, include the trailing zeros.

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.
 
I'll look at it tomorrow.

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.
 
> Snap is not there in NX 6
> 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.
 
OK, attached is a GRIP program which will open a designated folder and will read the data files in the folder and will create a spline, one for each data file read. Now you must enter the full path name to the folder including the folder name but no trailing '\'. The assumption is that the your data files will be formatted exactly the same as your sample files were. This program will read data files with up to 1,000 X,Y,Z records and can create up to 1,000 splines. In other words, you can create 1,000 splines each with 1,000 data points. Note that when the program is finished, you'll get a message stating "End of Data Files". When you select OK in this message dialog, the program will halt.

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.
 
 http://files.engineering.com/getfile.aspx?folder=b176990f-7acd-4c05-adcb-83eca3d34cc1&file=Spline_from_pts_file.zipper
Status
Not open for further replies.

Part and Inventory Search

Sponsor