Read a FreeCAD document

Read a FreeCAD document#

.FCStd is FreeCAD’s native document format: a zip archive carrying Document.xml plus one BREP per part. pyvista_cad.read_fcstd parses the manifest and tessellates the BREPs via OCP, no FreeCAD binary required.

This example reads a real part straight from the FreeCAD parts library (CC-BY 3.0, FreeCAD-library contributors): an M3 nyloc lock nut, and walks the resulting pyvista.MultiBlock.

Why this matters: FreeCAD is the dominant open-source MCAD package. Reading FCStd without a FreeCAD install lets analysis pipelines pick up community parts directly.

import pyvista as pv

import pyvista_cad
from pyvista_cad.examples import downloads

Read the real FCStd document.

MultiBlock (0x7f6faf5e69e0)
  N Blocks:   16
  X Bounds:   -3.175e+00, 3.175e+00
  Y Bounds:   -3.175e+00, 3.175e+00
  Z Bounds:   -2.000e-01, 3.856e+00


Render the nut.

for _, part in mb.cad.walk():
    part['elevation'] = part.points[:, 2]

pl = pv.Plotter()
pl.cad.add(mb, scalars='elevation', cmap='cividis')
pl.show()
read fcstd

Total running time of the script: (0 minutes 0.770 seconds)