trimesh.exchange.misc module

Functions

load_dict(data, **kwargs)

Load multiple input types into kwargs for a Trimesh constructor.

load_meshio(file_obj[, file_type])

Load a meshio-supported file into the kwargs for a Trimesh constructor.

load_msgpack(blob, **kwargs)

Load a dict packed with msgpack into kwargs for

trimesh.exchange.misc.load_dict(data, **kwargs)

Load multiple input types into kwargs for a Trimesh constructor. Tries to extract keys: ‘faces’ ‘vertices’ ‘face_normals’ ‘vertex_normals’

Parameters
  • data (accepts multiple forms) –

    -dict: has keys for vertices and faces as (n,3) numpy arrays -dict: has keys for vertices/faces (n,3) arrays encoded as dicts/base64

    with trimesh.util.array_to_encoded/trimesh.util.encoded_to_array

    -str: json blob as dict with either straight array or base64 values -file object: json blob of dict

  • file_type (not used) –

Returns

loaded – -vertices: (n,3) float -faces: (n,3) int -face_normals: (n,3) float (optional)

Return type

dict with keys

trimesh.exchange.misc.load_meshio(file_obj, file_type=None, **kwargs)

Load a meshio-supported file into the kwargs for a Trimesh constructor.

Parameters
  • file_obj (file object) – Contains a meshio file

  • file_type (str) – File extension, aka ‘vtk’

Returns

loaded – kwargs for Trimesh constructor

Return type

dict

trimesh.exchange.misc.load_msgpack(blob, **kwargs)

Load a dict packed with msgpack into kwargs for a Trimesh constructor

Parameters

blob (bytes) – msgpack packed dict containing keys ‘vertices’ and ‘faces’

Returns

loaded – Keyword args for Trimesh constructor, aka mesh=trimesh.Trimesh(**loaded)

Return type

dict