plyio

PLY file format.

This module implements support for reading and writing of PLY files.

class plyio.PlyHeaderElement(name: str, count: int, properties: List[PlyHeaderProperty])

Header information about one element.

count: int

Number of items

element_size() int | None

The total size of all properties of one element.

name: str

Name of the element

properties: List[PlyHeaderProperty]

List of properties

to_header_line() str

Format a property element line.

class plyio.PlyHeaderProperty(name: str, kind: str, size: int | None)

Header information about one property.

kind: str

Type (char, uchar, short, int, float, list int int, …)

name: str

Name of the property

size: int | None

Size of one item in bytes

to_header_line() str

Format a property header line.

class plyio.PlyMesh(vertices: ndarray, indices: ndarray, normals: ndarray | None, header_elements: List[PlyHeaderElement])

All mesh data of a PLY file.

property attributes: ndarray

Get auxiliary vertex attributes.

has_attributes() bool

Are auxiliary vertex attributes available?

header_elements: List[PlyHeaderElement]

The list of all PLY header elements.

indices: ndarray

The triangle data consisting of three vertex indices per triangle.

normals: ndarray | None

The normal vectors.

property positions: ndarray

Get vertex positions only (without auxiliary vertex attributes).

vertices: ndarray

The vertex data including vertex position and auxiliary vertex attributes.

plyio.read_ply(ply_path: Path) PlyMesh

Read a PLY mesh file.

plyio.read_ply_header_line(fp) str

Read one header line.

plyio.try_parse_ply_header_element(line: str) PlyHeaderElement | None

Try to parse one element from a header line.

plyio.try_parse_ply_header_property(line: str) PlyHeaderProperty | None

Try to parse one property from a header line.

plyio.write_ply(ply_path: Path, mesh: PlyMesh) None

Write a PLY mesh file.

plyio.write_ply_header_line(fp, line: str) None

Write one header line.