m3sh.obj.

write#

write(filename, append=False, absolute=True, **data)#

Write as .obj file.

This is a low-level function used by Mesh instances. See the notes below for usage instructions.

Parameters:
filenamestr

Name of output file.

appendbool, optional

Append to file if it exists.

absolutebool, optional

Pass False if indices are negative, i.e., relative. If True, absolute indices are assumed as 0-based.

**data

Keyword arguments.

Notes

Data to be stored in the file is passed via keyword arguments:

>>> mesh.write('output-file.obj', tag=value, ...)

This assumes that value can be interpreted as a 2-dimensional array. The contents of each row are written to a line that starts with the given tag (keyword).

Generically we want to store a list of points (used as vertices) and as list of faces. Assuming that points is array_like and faces is a nested list of integers, this can be achieved by

>>> write('file.obj', v=points, f=faces)

Specifying faces

Each entry of a face (a vertex definition) can be a single integer or a 3-tuple of integers. Tuple entries are interpreted as v/vt/vn triples, missing entries have to be specified as None values. Indices used in vertex definitions can be absolute (i.e., non-negative, 0-based) or relative (i.e., negative). Absolute and relative indices may not be mixed.