Reading STL Files

STL files can be read using the functions in the main stl module.

stl.read_ascii_file(file)

Read an STL file in the ASCII format.

Takes a file-like object (supporting a read method) and returns a stl.Solid object representing the data from the file.

If the file is invalid in any way, raises stl.ascii.SyntaxError.

stl.read_binary_file(file)

Read an STL file in the binary format.

Takes a file-like object (supporting a read method) and returns a stl.Solid object representing the data from the file.

If the file is invalid in any way, raises stl.binary.FormatError.

stl.read_ascii_string(data)

Read geometry from a str containing data in the STL ASCII format.

This is just a wrapper around read_ascii_file() that first wraps the provided string in a StringIO.StringIO object.

stl.read_binary_string(data)

Read geometry from a str containing data in the STL binary format.

This is just a wrapper around read_binary_file() that first wraps the provided string in a StringIO.StringIO object.