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
.stepor.stpfile.- 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 singlepyvista.PolyData. WhenFalse, return apyvista.MultiBlockwith one block per STEP part.- backend{‘build123d’, ‘cascadio’}, optional
Explicit backend selection. By default,
build123dis used when available, otherwisecascadio.- **_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=Falseapyvista.MultiBlockis returned: root field datacad.source_format/cad.reader/cad.backend/cad.unitsis set, per-partcad.color/cad.label/cad.transformis populated where the STEP carries it, and nested STEP sub-assemblies become nestedpyvista.MultiBlockblocks (recursion is unbounded over the CAF assembly tree). Withmerge=Truethe parts are flattened bypyvista.MultiBlock.combine()into a singlepyvista.PolyData; only the rootcad.source_format/cad.reader/cad.backend/cad.unitssurvive, and per-partcad.color/cad.label/cad.transformis dropped by the merge.
- Raises:
- FileNotFoundError
If
pathdoes not exist.- pyvista_cad.CadReadError
If parsing fails.
- pyvista_cad.OptionalDependencyError
If no STEP backend is installed.
- Parameters:
- Return type:
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'