Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

export spline data points to a file 2

Status
Not open for further replies.

vickieaz

Mechanical
Feb 11, 2015
8
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.
 
Replies continue below

Recommended for you

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.
 
 http://files.engineering.com/getfile.aspx?folder=ca996d29-8d49-45f0-b418-a24476a354a8&file=Pts_Along_Any_Curve_to_text-file.zipper
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
 
Here is a simple VB program to do the same sort of thing by calling SNAP functions:

Code:
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.
 
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.
 
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
 
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.
 
Hi John, I tried typing w.o .txt but got the same error. What kind of curve the GRIP recognize? Thank you!
 
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.
 
cool. i will try again. Thank you so much John!
 
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.
 
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!
 
OK, try the attached version. I modified it so that it snow aves the data file in the 'C:\Temp' folder. See if this works better.

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=ca44e676-1896-4b9b-926d-bffc3eeb62b8&file=Pts_Along_Any_Curve_to_txt-file.zipper
Status
Not open for further replies.

Part and Inventory Search

Sponsor