pyvista_cad.read_step

On this page

pyvista_cad.read_step#

read_step(path, /, *, linear_deflection=0.1, angular_deflection=0.5, merge=False, backend=None, **_)[source]#

Read a STEP file as a pyvista.MultiBlock (or merged PolyData).

Parameters:
pathstr or os.PathLike

Path to a .step or .stp file.

linear_deflectionfloat, default: 0.1

Maximum chordal deviation of the tessellation from the underlying analytical surface (model units). The faceted mesh deviates from the analytic B-rep surface by at most this value.

angular_deflectionfloat, default: 0.5

Maximum angular deviation in radians between adjacent triangles.

mergebool, default: False

When True, combine every part into a single pyvista.PolyData. When False, return a pyvista.MultiBlock with one block per STEP part.

backend{‘build123d’, ‘cascadio’}, optional

Explicit backend selection. By default, build123d is used when available, otherwise cascadio.

**_Any

Additional keyword arguments are accepted for forward compatibility with pyvista.read() and ignored here.

Returns:
pyvista.MultiBlock or pyvista.PolyData

Tessellated STEP geometry. With merge=False a pyvista.MultiBlock is returned: root field data cad.source_format / cad.reader / cad.backend / cad.units is set, per-part cad.color / cad.label / cad.transform is populated where the STEP carries it, and nested STEP sub-assemblies become nested pyvista.MultiBlock blocks (recursion is unbounded over the CAF assembly tree). With merge=True the parts are flattened by pyvista.MultiBlock.combine() into a single pyvista.PolyData; only the root cad.source_format / cad.reader / cad.backend / cad.units survive, and per-part cad.color / cad.label / cad.transform is dropped by the merge.

Raises:
FileNotFoundError

If path does not exist.

pyvista_cad.CadReadError

If parsing fails.

pyvista_cad.OptionalDependencyError

If no STEP backend is installed.

Parameters:
Return type:

MultiBlock | PolyData

Examples

Read the bundled STEP cube fixture:

>>> import pyvista as pv
>>> import pyvista_cad
>>> from pyvista_cad import read_step
>>> mesh = read_step(pyvista_cad.examples.step_cube)
>>> type(mesh).__name__
'MultiBlock'
>>> [round(b) for b in mesh.bounds]
[-5, 5, -5, 5, -5, 5]
>>> str(mesh.field_data['cad.source_format'][0])
'step'