trimesh.exchange.ply

trimesh.exchange.ply.export_draco(mesh, bits=28)

Export a mesh using Google’s Draco compressed format.

Only works if draco_encoder is in your PATH: https://github.com/google/draco

Parameters
  • mesh (Trimesh object) – Mesh to export

  • bits (int) – Bits of quantization for position tol.merge=1e-8 is roughly 25 bits

Returns

data – DRC file bytes

Return type

str or bytes

trimesh.exchange.ply.export_ply(mesh, encoding='binary', vertex_normal=None, include_attributes=True)

Export a mesh in the PLY format.

Parameters
  • mesh (trimesh.Trimesh) – Mesh to export.

  • encoding (str) – PLY encoding: ‘ascii’ or ‘binary_little_endian’

  • vertex_normal (None or include vertex normals) –

Returns

export

Return type

bytes of result

trimesh.exchange.ply.load_draco(file_obj, **kwargs)

Load a mesh from Google’s Draco format.

Parameters

file_obj (file- like object) – Contains data

Returns

kwargs – Keyword arguments to construct a Trimesh object

Return type

dict

trimesh.exchange.ply.load_ply(file_obj, resolver=None, fix_texture=True, prefer_color=None, *args, **kwargs)

Load a PLY file from an open file object.

Parameters
  • file_obj (an open file- like object) – Source data, ASCII or binary PLY

  • resolver (trimesh.visual.resolvers.Resolver) – Object which can resolve assets

  • fix_texture (bool) – If True, will re- index vertices and faces so vertices with different UV coordinates are disconnected.

  • prefer_color (None, 'vertex', or 'face') – Which kind of color to prefer if both defined

Returns

mesh_kwargs – Data which can be passed to Trimesh constructor, eg: a = Trimesh(**mesh_kwargs)

Return type

dict