pyvista_wasm.STLReader#

class pyvista_wasm.STLReader(path: str | Path)#

Bases: object

Reader for STL (STereoLithography) files (.stl).

Reads an STL file (ASCII or binary) and produces a Mesh that delegates parsing to VTK.wasm’s vtkSTLReader at render time. Python extracts only the vertex coordinates so that camera framing and bounding-sphere queries work before rendering.

Parameters:

path (str or Path) – Path to the .stl file.

Examples

>>> from pyvista_wasm import examples
>>> mesh = examples.download_cad_model()
>>> mesh.plot()
__init__(path: str | Path) None#

Initialize the reader with a file path.

Methods

__init__(path)

Initialize the reader with a file path.

read()

Read the STL file and return a Mesh.

Attributes

path

Return the file path.

property path: Path#

Return the file path.

Returns:

The path to the STL file.

Return type:

Path

read() _STLMesh#

Read the STL file and return a Mesh.

The full file content is base64-encoded and stored so that VTK.wasm can parse it at render time. Vertex coordinates are extracted on the Python side for bounding-sphere and camera-framing calculations.

Returns:

A mesh backed by the STL file content.

Return type:

Mesh

Raises:

ValueError – If the file format is invalid or unsupported.