pyvista_cad.add_cad

On this page

pyvista_cad.add_cad#

add_cad(plotter, obj, *, color=None, edges=True, edge_color=None, line_width=2.0, render_lines_as_tubes=False, silhouette=False, smooth=True, feature_angle=30.0, linear_deflection=0.1, angular_deflection=0.5, **mesh_kwargs)[source]#

Add obj to plotter rendered CAD-style.

Faces are drawn smooth-shaded with their triangle edges hidden; topological edges are overlaid as theme-coloured lines with a depth bias so they never z-fight the surface. This is the rendering primitive behind pyvista.Plotter.cad.add() and the .cad accessor’s plot().

Parameters:
plotterpyvista.Plotter

Target plotter.

objAny

MultiBlock / PolyData / DataSet / raw TopoDS / build123d / cadquery object. A plain mesh with no B-rep origin falls back to feature-edge extraction (approximate).

colorpyvista.ColorLike, optional

Face colour. Defaults to the active theme colour.

edgesbool, default: True

Draw the topological edge overlay.

edge_colorpyvista.ColorLike, optional

Edge colour. Defaults to pyvista.global_theme.edge_color.

line_widthfloat, default: 2.0

Edge line width.

render_lines_as_tubesbool, default: False

Render edges as tubes (nicer at thick widths).

silhouettebool, default: False

Add a camera-tracking silhouette outline of the faces.

smoothbool, default: True

Use analytic normals for smooth (non-faceted) shading.

feature_anglefloat, default: 30.0

Crease angle for the no-B-rep feature-edge fallback.

linear_deflection, angular_deflectionfloat

Tessellation tolerances if obj is not yet meshed.

**mesh_kwargs

Forwarded to add_mesh() for the faces.

Returns:
dict

{'faces': <Actor>, 'edges': <Actor or None>}.

Parameters:
Return type:

dict[str, Any]

Examples

Add a build123d box to a plotter CAD-style (requires the [step] extra):

>>> import pyvista as pv
>>> pv.OFF_SCREEN = True
>>> import build123d as b3d
>>> from pyvista_cad import add_cad
>>> pl = pv.Plotter()
>>> actors = add_cad(pl, b3d.Box(10, 10, 10).wrapped)
>>> sorted(actors.keys())
['edges', 'faces']
>>> pl.close()