trimesh.exchange.stl

Exceptions

HeaderError

Functions

export_stl(mesh)

Convert a Trimesh object into a binary STL file.

export_stl_ascii(mesh)

Convert a Trimesh object into an ASCII STL file.

load_stl(file_obj, **kwargs)

Load an STL file from a file object.

load_stl_ascii(file_obj)

Load an ASCII STL file from a file object.

load_stl_binary(file_obj)

Load a binary STL file from a file object.

exception trimesh.exchange.stl.HeaderError

Bases: Exception

trimesh.exchange.stl.export_stl(mesh)

Convert a Trimesh object into a binary STL file.

Parameters

mesh (Trimesh object) –

Returns

export

Return type

bytes, representing mesh in binary STL form

trimesh.exchange.stl.export_stl_ascii(mesh)

Convert a Trimesh object into an ASCII STL file.

Parameters

mesh (trimesh.Trimesh) –

Returns

export – Mesh represented as an ASCII STL file

Return type

str

trimesh.exchange.stl.load_stl(file_obj, **kwargs)

Load an STL file from a file object.

Parameters

file_obj (open file-like object) – Containing STL data

Returns

loaded – kwargs for a Trimesh constructor with keys: vertices: (n,3) float, vertices faces: (m,3) int, indexes of vertices face_normals: (m,3) float, normal vector of each face

Return type

dict

trimesh.exchange.stl.load_stl_ascii(file_obj)

Load an ASCII STL file from a file object.

Parameters

file_obj (open file- like object) – Containing input data

Returns

loaded – kwargs for a Trimesh constructor with keys: vertices: (n,3) float, vertices faces: (m,3) int, indexes of vertices face_normals: (m,3) float, normal vector of each face

Return type

dict

trimesh.exchange.stl.load_stl_binary(file_obj)

Load a binary STL file from a file object.

Parameters

file_obj (open file- like object) – Containing STL data

Returns

loaded – vertices: (n,3) float, vertices faces: (m,3) int, indexes of vertices face_normals: (m,3) float, normal vector of each face

Return type

kwargs for a Trimesh constructor with keys: