trimesh.exchange.obj module

Functions

export_obj(mesh[, include_normals, …])

Export a mesh as a Wavefront OBJ file

load_obj(file_obj[, resolver, split_object, …])

Load a Wavefront OBJ file into kwargs for a trimesh.Scene object.

parse_mtl(mtl[, resolver])

Parse a loaded MTL file.

trimesh.exchange.obj.export_obj(mesh, include_normals=True, include_color=True)

Export a mesh as a Wavefront OBJ file

Parameters

mesh (trimesh.Trimesh) – Mesh to be exported

Returns

export – OBJ format output

Return type

str

trimesh.exchange.obj.load_obj(file_obj, resolver=None, split_object=False, group_material=True, **kwargs)

Load a Wavefront OBJ file into kwargs for a trimesh.Scene object.

Parameters
  • file_obj (file like object) – Contains OBJ data

  • resolver (trimesh.visual.resolvers.Resolver) – Allow assets such as referenced textures and material files to be loaded

  • split_object (bool) – Split meshes at each o declared in file

  • group_material (bool) – Group faces that share the same material into the same mesh.

Returns

kwargs – Keyword arguments which can be loaded by trimesh.exchange.load.load_kwargs into a trimesh.Scene

Return type

dict

trimesh.exchange.obj.parse_mtl(mtl, resolver=None)

Parse a loaded MTL file.

Parameters
  • mtl (str or bytes) – Data from an MTL file

  • resolver (trimesh.visual.Resolver) – Fetch assets by name from files, web, or other

Returns

mtllibs – Each dict has keys: newmtl, map_Kd, Kd

Return type

list of dict