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.

surface_area

The sum of the areas of all facets in the object.

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, attributes=None)

A facet (triangle) from a stl.Solid.

a

The length the side of the facet between vertices[0] and vertices[1]

area

The surface area of the facet, as computed by Heron’s Formula.

b

The length of the side of the facet between vertices[0] and vertices[2]

c

The length of the side of the facet between vertices[1] and vertices[2]

perimeter

The length of the perimeter of the facet.

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.