科研 Skill

CADSmith文本生成CAD

cadsmith-text-to-cad

Generates dimensionally exact CadQuery CAD from natural language using the CADSmith plan-code-validate-refine loop. Use when the user describes a part in words and wants a CAD model.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

CADSmith: text → validated CadQuery

Paper: J. Barkley, R. Loghmani, A. Barati Farimani, CADSmith: Multi-Agent CAD Generation with Programmatic Geometric Validation, arXiv:2603.26512. On their 100-prompt benchmark it reached a 100% execution rate (versus 95% zero-shot), median IoU 0.963 (versus 0.809), and mean Chamfer distance 0.74 (versus 28.4).

Use this skill when correctness is checked against a stated spec. For quick parametric parts, parametric-part-cad is lighter. For FreeCAD macros, use query2cad-freecad.

Setup: pip install cadquery trimesh scipy rtree matplotlib.

Workflow

S=scripts/cadsmith.py. Keep everything for a part in runs/<name>/.

  1. Plan. Write plan.json following references/agents.md: components, target bbox (mm), holes (diameter, count), expected n_solids, and constraints. Convert the prompt's diameters and pitch-circle diameters explicitly. Don't write code yet.
  2. Retrieve. python $S kb "<keywords from the plan: polarArray hole revolve keyway ...>". Read the entries, especially the pitfalls.
  3. Code. Write part.py with named dimensions, ending with result = ....
  4. Execute (inner loop, at most 3 repairs).
    python $S execute runs/x/part.py --out runs/x/v0
    
    On failure, save the traceback, run python $S kb "<keywords>" --errors runs/x/v0_metrics.json, fix only what it implicates, and log with python $S log --run runs/x --stage inner --note "...". After 3 failed repairs, stop and report a code-execution failure.
  5. Validate (outer loop).
    python $S check  --plan runs/x/plan.json --metrics runs/x/v0_metrics.json   # deterministic
    python $S render runs/x/v0.stl --out runs/x/v0_views.png                     # iso / high-rear / front
    
    Then run the Judge from references/agents.md with the prompt, code, metrics, check result, and image. Spawn an independent subagent for this when you can; the paper's point is that the generator mustn't grade itself. A kernel hard-fail (invalid or not watertight) fails regardless of the judge.
  6. Refine (at most 5). Log each attempt with python $S log --run runs/x --stage outer --note "<feedback>". When the ledger returns escalate: true (iteration 3 and later), change the construction approach.
  7. Deliver: STEP, STL, the three-view image, part.py, the plan, and a table comparing the kernel bbox, volume, and hole counts with the spec. Say whether the judge was independent, and list any feature the renders couldn't confirm (small gaps at joints are the paper's documented near-miss).

Benchmarking (optional)

With a reference model: python $S eval gen.stl ref.stl gives the Chamfer distance (sum of the two directional mean squared nearest-neighbour distances over 10k points), F1 at τ = 1 mm, and voxel IoU at 1 mm (coarsened above 100 mm). Everything is in absolute mm after bbox-centring and ICP, as in the paper.

Prompt conventions that help (from the benchmark)

Explicit mm dimensions, axis-annotated orientation (XY base, Z up), origin-centred geometry, and coordinates for holes and slots. If the user's prompt lacks these, state the assumptions in the plan before coding.

示例提示词

帮我用CADSmith方法根据文字描述生成一个带法兰的精确CadQuery零件。

所属插件

机械设计与先进制造面向机械设计与制造研究:文本/草图生成 CAD、FreeCAD/SolidWorks 参数化建模、机构综合与零件选型、公差与 GD&T、DFM 与设计评审、快速有限元与应力代理模型、增材制造工艺与缺陷预测、疲劳断裂寿命。

安装该插件会一并获得同领域的 35 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

CADSmith文本生成CAD能做什么?

Generates dimensionally exact CadQuery CAD from natural language using the CADSmith plan-code-validate-refine loop. Use when the user describes a part in words and wants a CAD model。

如何安装CADSmith文本生成CAD?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「CADSmith文本生成CAD」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

CADSmith文本生成CAD需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

CADSmith文本生成CAD经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。