API reference#
The public API of pyvista-cad is everything exported from the
top-level pyvista_cad namespace, plus the two .cad accessor
classes. Importing pyvista_cad registers the .cad accessor
on pyvista.DataSet and pyvista.MultiBlock and wires
the CAD readers into pyvista.read().
Readers and writers#
Format readers return a pyvista.PolyData or
pyvista.MultiBlock; writers take one and a path. IGES and
SCAD are read-only.
|
Read a STEP file as a |
|
Write a |
|
Read an IGES file using pyiges and return a pyvista dataset. |
|
Read a BREP file as a |
|
Write a |
|
Read a DXF file as a |
|
Write a |
|
Read a 3MF file as a |
|
Write a |
|
Read an IFC file as a |
|
Read a FreeCAD document as a |
|
Compile an OpenSCAD source file and return the resulting mesh. |
|
Read a glTF/GLB file and enrich it with manifest metadata. |
|
Attach glTF node names / extras to a dataset's field data. |
Bridges to other CAD libraries#
Convert between PyVista meshes and build123d, CadQuery, gmsh, and
raw OCCT TopoDS shapes.
trimesh interop is provided by pyvista core
(pyvista.from_trimesh(), pyvista.to_trimesh()) and by the
pyvista-trimesh package’s .trimesh accessor (install
pyvista-cad[trimesh]); pyvista-cad does not duplicate it.
|
Convert a |
|
Wrap a |
|
Convert a |
|
Wrap a |
|
Tessellate a raw OCCT |
|
Build a faceted |
|
Pull the current gmsh model into a |
|
Install a PyVista mesh as the current gmsh model (in place). |
CAD-view conversion helpers#
The free functions behind the CAD-friendly render: resolve a mesh or
raw shape into a {'faces', 'edges'} pyvista.MultiBlock,
or plot it directly.
|
Add |
|
One-shot CAD-friendly plot of |
|
Resolve |
Collapse a |
|
|
Return the edges PolyData stashed on |
|
Extract topological edges of |
|
Tessellate |
Accessors#
pyvista-cad registers a dual .cad accessor: PyVista resolves
.cad to CadDataSetAccessor on a pyvista.DataSet
and to CadMultiBlockAccessor on a pyvista.MultiBlock,
by object type. They share the metadata, split, conversion, and
plotting surface; the MultiBlock accessor adds assembly-tree
traversal (walk(),
find(),
assembly_tree(),
flatten()).
Construct PyVista meshes from external CAD objects with the
module-level from_build123d(), from_cadquery(),
from_topods(), and from_gmsh()
functions (see Bridges to other CAD libraries above). The accessor
exposes only to_* (outgoing) conversions; it is bound to an
existing dataset, so it has no from_* constructors.
|
The |
|
The |
CadDataSetAccessor members#
Originating CAD format ('STEP', 'DXF', ...) or |
|
Canonical unit string or |
|
Dataset-level label, or |
|
Dataset-level RGB color, or |
|
Live |
|
Sorted unique DXF / cell-data layer names. |
|
Whether this dataset has a recoverable B-rep origin. |
|
Tessellation deflections last used to build this mesh. |
|
|
Update |
|
Write the standard |
|
Split into one block per |
|
Split a composite mesh by the values of a per-cell label array. |
|
Split into one block per per-cell RGB color. |
Return the exact volume from the cached |
|
Return the exact centre of mass from the cached |
|
Wrap the dataset as a faceted |
|
Wrap the dataset as a faceted |
|
Build a faceted |
|
|
Install the dataset as the current gmsh model. |
|
Write this dataset as a DXF file. |
|
Write to |
|
Write to |
|
Write to |
|
Write to |
|
Re-tessellate this mesh from its cached originating B-rep. |
|
CAD-friendly plot: shaded faces + topological edges. |
|
Resolve to a |
CadMultiBlockAccessor members#
|
Update |
|
Write the standard |
Walk the MultiBlock tree depth-first. |
|
|
Filter the MultiBlock tree. |
Collapse a nested MultiBlock into a flat MultiBlock of leaves. |
|
Fuse the entire MultiBlock into one |
|
Return a pure-data view of the MultiBlock hierarchy. |
|
Combine and split into one block per layer. |
|
Combine the assembly, then split by per-cell label value. |
|
Combine and split into one block per per-cell color. |
|
Sum exact volume across all BREP-cached leaves. |
|
Wrap as a faceted |
|
Wrap as a faceted |
|
Build a faceted |
|
|
Install this MultiBlock as the current gmsh model. |
|
Write this MultiBlock as a DXF file. |
|
Write to |
|
Write to |
|
Write to |
|
Write to |
|
Re-tessellate the combined assembly from its cached B-rep. |
|
CAD-friendly plot: shaded faces + topological edges. |
|
Resolve to a |
Metadata#
|
Bag of CAD-flavored metadata derived from a PyVista dataset. |
Exceptions and warnings#
Base class for all pyvista-cad errors. |
|
Raised when a CAD file cannot be read. |
|
Raised when a CAD file cannot be written. |
|
Raised when a cached originating |
|
Raised when a |
|
Raised when an optional backend is needed but not installed. |
|
Raised when OCCT tessellation fails for a given shape. |
|
Raised when a requested format is not supported. |
|
Category for pyvista-cad data or feature-loss warnings. |
Example data#
Bundled fixture files and downloadable example datasets.
Return the path to the bundled L-bracket STEP fixture. |
|
Return the path to the bundled 2D mechanical drawing DXF fixture. |
|
Return the path to the bundled two-part 3MF assembly fixture. |
|
Return the path to the bundled small building IFC fixture. |
Return the NIST AM Bench 2022 LPBF bridge specimen (STEP). |
|
Return the small NIST AM Bench recoater-guide fixture (STEP). |
|
Return the NIST AM Bench build-plate layout assembly (STEP). |
|
Return a centrifugal impeller exported from SolidWorks (IGES). |
|
Return a single-family-house BIM model from buildingSMART (IFC4). |
|
Return the 3MF Consortium colored dodecahedron chain (3MF). |
|
Return the Khronos ToyCar reference asset (binary glTF). |
|
Return a multi-layer 2D DXF drawing (layers |
|
Return a parametric ISO metric fastener library (OpenSCAD). |
|
Return an M3 nyloc lock nut from the FreeCAD parts library (FCStd). |
|
Return as-designed CAD and as-scanned PLY of one T-LESS part. |