Data Types

The following data types, with stl.Solid as the root, are used to represent data read from or to be written to an STL file.

class stl.Solid(name=None, facets=None)

A solid object; the root element of an STL file.

add_facet(*args, **kwargs)

Append a new facet to the object. Takes the same arguments as the stl.Facet type.

write_ascii(file)

Write this object to a file in STL ascii format.

file must be a file-like object (supporting a write method), to which the data will be written.

write_binary(file)

Write this object to a file in STL binary format.

file must be a file-like object (supporting a write method), to which the data will be written.

class stl.Facet(normal, vertices)

A facet (triangle) from a stl.Solid.

class stl.Vector3d(x, y, z)

Three-dimensional vector.

Used to represent both normals and vertices of stl.Facet objects.

This is a subtype of tuple, so can also be treated like a three-element tuple in (x, y, z) order.

x

The X value of the vector, which most applications interpret as the left-right axis.

y

The Y value of the vector, which most applications interpret as the in-out axis.

z

The Z value of the vector, which most applications interpret as the up-down axis.