trimesh.exchange.export

Functions:

export_dict(mesh[, encoding])

Export a mesh to a dict

export_dict64(mesh)

Export a mesh as a dictionary, with data encoded to base64.

export_glb(scene[, extras, include_normals])

Export a scene as a binary GLTF (GLB) file.

export_gltf(scene[, extras, …])

Export a scene object as a GLTF directory.

export_json(mesh)

export_mesh(mesh, file_obj[, file_type, …])

Export a Trimesh object to a file- like object, or to a filename

export_msgpack(mesh)

export_obj(mesh[, include_normals, …])

Export a mesh as a Wavefront OBJ file.

export_scene(scene, file_obj[, file_type])

Export a snapshot of the current scene.

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.

export_urdf(mesh, directory[, scale, color])

Convert a Trimesh object into a URDF package for physics simulation.

scene_to_dict(scene[, use_base64])

Export a Scene object as a dict.

trimesh.exchange.export.export_dict(mesh, encoding=None)

Export a mesh to a dict

Parameters
  • mesh (trimesh.Trimesh) – Mesh to be exported

  • encoding (str or None) – Such as ‘base64’

Returns

export – Data stored in dict

Return type

dict

trimesh.exchange.export.export_dict64(mesh)

Export a mesh as a dictionary, with data encoded to base64.

trimesh.exchange.export.export_json(mesh)
trimesh.exchange.export.export_mesh(mesh, file_obj, file_type=None, resolver=None, **kwargs)

Export a Trimesh object to a file- like object, or to a filename

Parameters
  • file_obj (str, file-like) – Where should mesh be exported to

  • file_type (str or None) – Represents file type (eg: ‘stl’)

  • resolver (None or trimesh.resolvers.Resolver) – Resolver to write referenced assets to

Returns

exported – Result of exporter

Return type

bytes or str

trimesh.exchange.export.export_msgpack(mesh)
trimesh.exchange.export.export_scene(scene, file_obj, file_type=None, **kwargs)

Export a snapshot of the current scene.

Parameters
  • file_obj (str, file-like, or None) – File object to export to

  • file_type (str or None) – What encoding to use for meshes IE: dict, dict64, stl

Returns

export – Only returned if file_obj is None

Return type

bytes

trimesh.exchange.export.scene_to_dict(scene, use_base64=False)

Export a Scene object as a dict.

Parameters

scene (trimesh.Scene) – Scene object to be exported

Returns

as_dict – Scene as a dict

Return type

dict