41. plugins.export — Classes and functions for exporting geometry in various formats.

  • ObjFile: wavefront .obj format
  • PlyFile: .ply format

These classes do not necessarily implement all features of the specified formats. They are usually fitted to export and sometimes imports simple mesh format geometries.

41.1. Classes defined in module plugins.export

class plugins.export.ObjFile(filename)[source]

Export a mesh in OBJ format.

This class exports a mesh in Wavefront OBJ format (see https://en.wikipedia.org/wiki/Wavefront_.obj_file).

The class instantiator takes a filename as parameter. Normally, the file name should end in ‘.obj’, but anything is accepted. The ObjFile instance is a context manager.

Usage:

with ObjFile(PATH_TO_OBJFILE) as fil:
    fil.write(MESH)
write(mesh, name=None)[source]

Write a mesh to file in .obj format.

mesh is a Mesh instance or another object having compatible coords and elems attributes. name is an optional name of the object.

class plugins.export.PlyFile(filename, binary=False)[source]

Export a mesh in PLY format.

This class exports a mesh in Polygon File Format (see https://en.wikipedia.org/wiki/PLY_(file_format)).

The class instantiator takes a filename as parameter. Normally, the file name should end in ‘.ply’, but anything is accepted. The PlyFile instance is a context manager.

Usage:

with PlyFile(PATH_TO_PLYFILE) as fil:
    fil.write(MESH)
write(mesh, comment=None, color_table=None)[source]

Write a mesh to file in .ply format.

Parameters:

  • mesh: a Mesh instance or another object having compatible coords and elems attributes.
  • comment: an extra comment written into the output file.
  • color_table: BEWARE! THIS IS SUBJECT TO CHANGES!

color_table currentlyis a list of 2 elements. The first entry is a string that can assume 2 values ‘v’ or ‘e’, to indicate whether the color table represents nodal or element values. The second entry is an array of shape (ncoords,3) or (nelems,3) of interger RGB values between 0 and 255. If RGB values are passed as float between 0 and 1, they will be converted to RGB integers.