[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80090":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":14,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":21,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":26,"discoverSource":27},80090,"pyvista-cad","pyvista\u002Fpyvista-cad","pyvista","The canonical CAD interop and plotting layer for PyVista","https:\u002F\u002Fcad.pyvista.org\u002F",null,"Python",60,8,1,0,2,43.56,"MIT License",false,"main",true,[],"2026-06-12 04:01:26","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fpyvista\u002Fpyvista\u002Fraw\u002Fmain\u002Fdoc\u002Fsource\u002F_static\u002Fpyvista_logo.svg\" alt=\"PyVista\" width=\"400\" \u002F>\n\u003C\u002Fp>\n\n# pyvista-cad\n\n[![CI](https:\u002F\u002Fgithub.com\u002Fpyvista\u002Fpyvista-cad\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fpyvista\u002Fpyvista-cad\u002Factions\u002Fworkflows\u002Fci.yml)\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fpyvista-cad.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fpyvista-cad\u002F)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](LICENSE)\n\n**CAD format reading, writing, and CAD-style plotting for [PyVista](https:\u002F\u002Fgithub.com\u002Fpyvista\u002Fpyvista).**\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fpyvista\u002Fpyvista-cad\u002Fmain\u002Fdoc\u002F_static\u002Fhero.png\" alt=\"The same flange shown two ways: a generic mesh viewer drawing the raw triangulation on the left, and pyvista-cad drawing smoothly shaded faces with the model's topological edges on the right.\" width=\"90%\">\n\u003C\u002Fp>\n\n`pyvista-cad` adds CAD-format support to PyVista: STEP, IGES, BREP, DXF, 3MF, IFC, FreeCAD `.fcstd`, OpenSCAD `.scad`, and glTF. It registers a `.cad` accessor on every `pv.DataSet` \u002F `pv.MultiBlock` and wires reader entries into `pv.read(...)`. It also adds CAD-style rendering: smoothly shaded faces with the model's topological B-rep edges instead of triangle-mesh noise, via `.cad.plot()` and a `plotter.cad` component. No monkey-patching, no forks, no direct VTK calls.\n\n## Install matrix\n\n| Extra          | Adds                    | Formats unlocked                    |\n| -------------- | ----------------------- | ----------------------------------- |\n| (base)         | ezdxf                   | DXF read + write, glTF read + write |\n| `[step]`       | build123d, cadquery-ocp | STEP, BREP, FCStd, build123d bridge |\n| `[step-light]` | cascadio                | STEP (read-only, faster, no colors) |\n| `[3mf]`        | lib3mf                  | 3MF read + write                    |\n| `[ifc]`        | ifcopenshell            | IFC read (with property sets)       |\n| `[iges]`       | pyiges[full]            | IGES read                           |\n| `[openscad]`   | (uses `openscad` CLI)   | SCAD read                           |\n| `[full]`       | all of the above        | every supported format              |\n\n**Python support:** 3.10 – 3.14.\n\ntrimesh interop is provided by pyvista core (`pyvista.from_trimesh`, `pyvista.to_trimesh`) and the `pyvista-trimesh` package's `.trimesh` accessor (install `pyvista-cad[trimesh]`); pyvista-cad does not duplicate it.\n\nFEA meshing via gmsh is intentionally out of scope. `gmsh` is GPLv2+ and would virally license any closed-source product that linked it, so `pyvista-cad`'s dependency set stays fully permissive (MIT \u002F BSD \u002F Apache, plus LGPL-with-exception for the OpenCascade and IFC backends). For CAD-to-tet workflows, drive `gmsh` directly and read the resulting `.msh` file back with `pv.read` (PyVista routes `.msh` through `meshio`); the `scikit-gmsh` package wraps the live-model API if you prefer that.\n\n```bash\npip install pyvista-cad           # DXF and glTF only\npip install pyvista-cad[step]     # add STEP, BREP, FCStd\npip install pyvista-cad[full]     # everything\n```\n\n## Quick start\n\n```python\nimport pyvista as pv\nimport pyvista_cad  # registers the .cad accessor and reader entries\n\nmesh = pv.read('part.step')              # MultiBlock of parts with cad.color, cad.label\nmesh.plot(show_edges=True)\n\nfloorplan = pv.read('floor.dxf')         # PolyData with Layer cell data\nlayers = floorplan.cad.split_by_layer()  # MultiBlock keyed on layer\n```\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fpyvista\u002Fpyvista-cad\u002Fmain\u002Fdoc\u002F_static\u002Freadme_quickstart.png\" alt=\"Two independent example fixtures. Left: a STEP part read with pv.read, drawn CAD-style with shaded faces and topological edges. Right: a DXF drawing split into colored per-layer blocks (body, centerlines, dimensions, holes).\" width=\"90%\">\n\u003C\u002Fp>\n\n## CAD-friendly plotting\n\nA generic mesh viewer draws the _triangulation_. With `show_edges=True` you see every facet edge, an artifact of the tessellation tolerance. A CAD application instead shows smoothly shaded faces with the model's _topological_ edges (the B-rep feature curves) on top. `pyvista-cad` reproduces that: analytic surface normals so a coarse mesh still shades round, topological edges recovered from the cached B-rep, triangle edges hidden.\n\n```python\nimport pyvista as pv\nimport pyvista_cad\nfrom pyvista_cad.examples import downloads\n\nmb = pyvista_cad.read_step(downloads.step_part_path())  # NIST AM Bench specimen\n\nmb.cad.plot()                       # shaded faces + topological edges\n\n# Or compose it into a scene, color faces by a scalar, keep the edges:\npart = mb[0]                        # a cached block keeps its B-rep\npart['height'] = part.points[:, 2]\npl = pv.Plotter()\npl.cad.add(part, scalars='height', cmap='viridis')\npl.show()\n```\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fpyvista\u002Fpyvista-cad\u002Fmain\u002Fdoc\u002F_static\u002Freadme_cad_plotting.png\" alt=\"The NIST AM Bench specimen. Left: cad.plot draws shaded faces with topological B-rep edges. Right: the same cached block colored by a height scalar with the viridis colormap, the topological edges still drawn.\" width=\"90%\">\n\u003C\u002Fp>\n\n`.cad.plot()` and the `plotter.cad` component accept a `MultiBlock`, `PolyData`, raw `TopoDS`, or a build123d \u002F cadquery object; a plain mesh with no B-rep origin degrades to crease feature edges.\n\n## Real-world workflow\n\nLoad a STEP assembly, locate a part, drive it through gmsh to a\ntetrahedral FEA mesh, then clip to expose the interior. `pv.read`\nhandles the resulting `.msh` file natively via `meshio`, so no extra\nPyVista dependency is needed.\n\n```python\nimport gmsh\nimport pyvista as pv\nimport pyvista_cad\nfrom pyvista_cad.examples import downloads\n\nassembly = pv.read(downloads.step_assembly_path())  # 3-part NIST build assembly\nprint(assembly.cad.assembly_tree())                 # nested dict of block names\nmatches = assembly.cad.find('*PartCAD')             # glob -> list of (path, block)\npath, part = matches[0]\n\ngmsh.initialize()\ntry:\n    gmsh.model.occ.importShapes(downloads.step_part_path())\n    gmsh.model.occ.synchronize()\n    gmsh.option.setNumber('Mesh.MeshSizeMax', 2.0)\n    gmsh.model.mesh.generate(3)\n    gmsh.write('part.msh')\nfinally:\n    gmsh.finalize()\n\ngrid = pv.read('part.msh')                          # via meshio\ngrid = grid.extract_cells(grid.celltypes == 10)     # keep VTK_TETRA\nclip = grid.clip(normal='x', crinkle=True)\nclip.save('part_tets.vtu')                          # full tet mesh round-trips\n```\n\nThe Quick start uses bundled offline fixtures (`bracket_step_path()`, a parametric L-bracket committed as STEP; `drawing_dxf_path()`, a layered 2D drawing). The other examples pull real, openly licensed parts from `pyvista_cad.examples.downloads` (cached on first fetch) — the NIST AM Bench LPBF specimen and its 3-part build assembly.\n\n## Common tasks\n\n| Task                                      | How                                                                                       |\n| ----------------------------------------- | ----------------------------------------------------------------------------------------- |\n| Read a STEP assembly with per-part colors | `pv.read('a.step')` returns a `MultiBlock`; each block has `cad.color` and `cad.label`    |\n| Split a DXF by layer                      | `pv.read('a.dxf').cad.split_by_layer()`                                                   |\n| Round-trip a 3MF print                    | `pyvista_cad.write_three_mf(mb, 'b.3mf')` (object color + units kept)                     |\n| Load an IFC building and filter walls     | `mb = pv.read('b.ifc'); walls = mb.cad.find(ifc_type='IfcWall')`                          |\n| Read IFC property sets                    | `json.loads(block.field_data['cad.psets'][0])` returns the source `Pset_*` \u002F `Qto_*` dict |\n| Convert build123d to PyVista              | `pyvista_cad.from_build123d(part)` (preserves color, label, transform)                    |\n| Mesh a STEP for FEA in gmsh               | Drive `gmsh` directly, `gmsh.write('out.msh')`, then `pv.read('out.msh')` (uses `meshio`) |\n| Generate a signed distance field from CAD | see `examples\u002F05_workflows\u002Fcad_to_signed_distance.py`                                     |\n\n## Licensing\n\n`pyvista-cad` is MIT. Every runtime dependency is either permissive\n(MIT \u002F BSD \u002F Apache) or LGPL with the OpenCascade exception. **No\nGPL code is pulled in by any extra**, which makes the package safe to\nuse in closed-source \u002F proprietary products subject to the standard\nLGPL dynamic-link obligations. See [LICENSES.md](LICENSES.md) for the\nfull dependency-by-dependency breakdown, the LGPL compliance notes, and the rationale for not depending on\n`gmsh`.\n\n## Fidelity and limitations\n\nRound-trip fidelity varies by format. Tessellated formats (STEP, IGES, BREP, FCStd) discretize analytic surfaces on read; the originating B-rep is cached so `tessellate()` can refine it. DXF and 3MF round-trip geometry and metadata within documented tolerances. IGES and SCAD are read-only.\n","pyvista-cad 是一个为 PyVista 添加 CAD 格式支持的扩展库，能够读写多种 CAD 文件格式并提供高质量的 CAD 风格渲染。该项目支持 STEP、IGES、BREP、DXF、3MF、IFC、FreeCAD `.fcstd`、OpenSCAD `.scad` 和 glTF 等常见 CAD 格式，并通过 `.cad` 访问器和 `pv.read(...)` 方法将这些功能集成到 PyVista 中。此外，它还引入了 CAD 风格的绘图功能，如平滑着色的面和模型拓扑边，以替代三角网格噪声。适用于需要在 Python 环境下处理 CAD 数据的场景，比如工程设计、制造模拟或科学研究等。","2026-06-11 03:59:12","CREATED_QUERY"]