This module defines bothe the basic routines to write geometrical data to a file and the specialized exporters to write files in a number of well known standardized formats.
The basic routines are very versatile as well as optimized (using the version in the pyFormex C-library) and allow to easily create new exporters for other formats.
Classes defined in module filewrite
Functions defined in module filewrite
Write an array of numerical data to an open file.
Parameters:
fil: an open file object
data: a numerical array of int or float type
sep: a string to be used as separator in case no fmt is specified. If an empty string, the data are written in binary mode. This is the default. For any other string, the data are written in ascii mode with the specified string inserted as separator between any two items, and a newline appended at the end. In both cases, the data are written using the numpy.tofile function.
fmt: a format string compatible with the array data type. If specified, the sep argument is ignored and the data are written according to the specified format. This uses the pyFormex functions misc.tofile_int32 or misc.tofile_float32, which have accelerated versions in the pyFormex C library. This also means that the data arrays will be force to type float32 or int32 before writing.
The format string should contain a valid format converter for a a single data item in both Python and C. They should also contain the necessary spacing or separator. Examples are ‘%5i ‘ for int data and ‘%f,’ or ‘%10.3e’ for float data. The array will be converted to a 2D array, keeping the length of the last axis. Then all elements will be written row by row using the specified format string, and the end string will be added after each row.
end: a string to be written at the end of the data block (if no fmt) or at the end of each row (with fmt). The default value is a newline character.
Write an indexed array of numerical data to an open file.
Write a mesh of polygons to a file in OFF format.
Parameters:
Write a mesh of triangles to a file in GTS format.
Parameters:
Write a collection of triangles to an STL file.
Parameters:
Write a binary stl.
Parameters:
Write a collection of triangles to an ascii .stl file.
Parameters: