×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

export spline data points to a file
2

export spline data points to a file

export spline data points to a file

(OP)
I am currently working with UG NX 8.5 and I am trying to find out what is the best way or if there is any way where I can export spline data points to a file. I have a curve generated by offset the edge of a surface.

I would like to be able to either create points of the curve to a text file so that it can be formatted as x,y,z coordinates and import the information to MATLAB.

Anyone who has valuable advice would be much appreciated.

RE: export spline data points to a file

If you can execute GRIP programs, the attached program will do what you're looking for. Please read the description of how to use the program in the source file (with the extension '.grs'). After downloading the file, change the file extension from '.zipper' to '.zip' before attempting to extract the files.

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: export spline data points to a file

(OP)
Hi John,

It is so nice of you sharing the file. I run it through "File/Execute/Grip" and selected "Pts_Along_Any_Curve_to_txt-file.grx". A window showed up a blank line where I typed in "test.txt", then a window with "Name =" showed up. I selected the spline needed, then click "Yes", left "Points" as "50", clicked "OK", "Finish Program" and I received an Error Message saying "Data file Saving Error! Program Terminating!"

I'd like to ask for your suggestion on it?

Thank you!

Arwen

RE: export spline data points to a file

Here is a simple VB program to do the same sort of thing by calling SNAP functions:

CODE --> VB

Option Infer On
Imports Snap, Snap.Create, Snap.UI, Snap.InfoWindow
Imports System.Linq

Public Class MyProgram

    Public Shared Sub Main()

      ' Create a selection dialog for selecting a spline
      Dim dialog = Selection.SelectObject("Please select a spline")
      dialog.SetCurveFilter(Snap.NX.ObjectTypes.Type.Spline)

      ' Display the dialog and get a result
      Dim result = dialog.Show()

      ' Loop to write the spline knot points to the Info window
      If result.Response <> Response.Cancel And result.Response <> Response.Back Then
         Dim mySpline As NX.Spline = result.Object

         For Each t As Double In mySpline.Knots.Distinct()
            Dim pt = mySpline.Position(t)       ' Compute point at knot value
            WriteLine(pt)                       ' Write to Info window
         Next
        
      End If
        
    End Sub

End Class 

It writes the point coordinates to the Info window, and you can then copy/paste into Matlab, Excel, or anywhere else.

This is very basic, and it could be modified in many ways. For example:
(1) It could output some user-specified number of points on the spline, not just the knot-points.
(2) It could call NX/Open functions, rather than SNAP functions.
(3) It could write the text to a file rather than the Info window.
(4) It could write the point coordinates in some other format.

If any of those improvements are important to you, the code will be eay to revise.

RE: export spline data points to a file

Don't type the '.txt' in the name. Just type the name part of the file name.

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: export spline data points to a file

If i guess about the issue with the GRIP code, you tried to use a directory or file name with a space in the name.
If i remember things correct, GRIP programs don't like spaces, nor "non-english" characters.
( GRIP is very old, still running,)

Regards,
Tomas

RE: export spline data points to a file

(OP)
Thank you BubbaK for sharing.

RE: export spline data points to a file

(OP)
Hi Toost,I don't think I have spaces nor non-English characters included... - still, thanks for the information. I will try to avoid it for future reference.

RE: export spline data points to a file

(OP)
Hi John, I tried typing w.o .txt but got the same error. What kind of curve the GRIP recognize? Thank you!

RE: export spline data points to a file

It should work for any curve. I tested the program before I posted it, using NX 8.5, and it worked fine.

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: export spline data points to a file

(OP)
cool. i will try again. Thank you so much John!

RE: export spline data points to a file

Are you running under Teamcenter? If so, I'll have to make a small adjustment to the program since it tries to save the data file in the same folder as the part file, but of course, is you're running under Teamcenter, that's something that GRIP is not able to do. I'll have to pick an arbitrary but easy to access folder, usually the Windows 'Temp' folder.

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: export spline data points to a file

(OP)
Hi John,

I opened the native program. I'd like to ask is it possible related to the administrator's access of my PC?

Again, appreciate your time and effort.

Thanks!

RE: export spline data points to a file

(OP)
It works!! Thank you so much John!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources