Skip to main content

How do I format a point curve text (*.txt) file for import?

This tutorial requires:

DesignSpark Mechanical V6.0

Here is how you can customise a point curve text (*.txt) file and the expected behaviour of the imported curve:

  • A spline curve is created by default or if the option Polyline=False is used. If the option Polyline=True is used, then the points are connected by straight line segments.

  • By default, 2D curves are created. When specifying 2D curves, the first column of the data points must be an integer and gives the height of the plane of one of the curves. The beginning of a new curve is specified by changing this height from one line to the next. If option 3D=True is used, the curves can be 3D.

  • Use the Fit keyword to specify whether Curve Fitting or Interpolation is used. Fit=True uses Curve Fitting. Curve Fitting creates a curve that "Fits" the data points using a specified tolerance. The curve may not pass exactly through all points and the distance from the curve to the point will be within the tolerance.

  • Use the Fittol keyword when Fit=True to specify the Curve Fitting tolerance in model units. For example, Fittol=1.0e-2

  • The curve below uses Curve Fitting (i.e., Fit=True). A large tolerance (Fittol=2.0) is used to exaggerate the fact that the curve does not pass through the points but only gets within the specified tolerance.

    217986ffae57153aa92fcd55bc7c4f21f7b9fd4b.png

  • Fit=False uses Interpolation. Interpolation requires that the curve pass exactly through all the points. An interpolation method is used to build a continuous curve through all the points. The curve below is interpolated (i.e. Fit=False). There are seven points in the file and the curve passes exactly through each one.

    f695a422e67fedada62be77c0a0e857af955b06c.png

Key items to note:

  1. Multiple curves are separated by blank lines.

  2. You can import point curve text files that contain single-point curves, which will be created as points.

  3. PointSingle location in the sketch grid. 2-D object that has no height, width, or length. The origin, an axis, and a vertex are examples of points. Use the Point tool to sketch a point on the sketch grid. Points are useful as a dimensional reference, for splitting, and for creating a point on a line or curve through which you want to draw a three-point circle.-curve text files opened or inserted in display a closed curve when the file has a repeated value.

  4. Curves can be imported to coordinate systems or other geometry like other imported objects.

  5. If there is an error reading the input text file, a message will appear with the line number of the error in parentheses followed by the text appearing on that line.

The following example shows the contents of a point curve text file on the left and the 3D curves it creates on the right:

  • Note that the point coordinates are (Z, X, Y).
  • For example (1, 2, 3) is (Z=1, X=2, Y=3).

3d=true
Polyline=false

1 0 0
1 0 1
1 1 0
1 1 1
2 0 1
2 1 0

3 0 0
3 0 1
3 1 0

0d271aa27292a4830fc28fc2f3e545888f9f368f.png

Keywords

polyline=false - spline curves are created.

polyline=true - straight lines are created.

3d=true - 3D curves are created.

3d=false - curves are two-dimensional. This is also the case if the option is not set.

fit=true - use Curve Fitting.

Curve Fitting finds the "Best Fit" through the points.

Does not require the curve to pass through all of the points

fit=false - use Interpolation.

Interpolation forces the curve to pass through all the points in the file.

fittol=1.0e-2 - Curve Fitting tolerance in the units used in the file.

The blank line after the first set of coordinates indicates that the next set of coordinates is a new curve.

You can copy the file contents above and paste them into a text file, then use e9f754c97a331f85e6f8769b9e339d25c105657b.png File to try it yourself.

RS DesignSpark is the go-to platform for students, makers, hobbyists and professional design engineers, providing design resources such as the award winning DesignSpark PCB and DesignSpark Mechanical CAD software. Join the community today at https://www.rs-online.com/designspark/register