Parametric 3D CAD via build123d. Generate STEP, STL, SVG from Python scripts. Use when the user asks to design, model, create, or export 3D parts, enclosures, mounts, brackets, or mechanical components.
通过build123d实现参数化3D CAD。该技能提供用于生成和测量3D实体的Python脚本。使用exec工具运行它们。
bash
cd {baseDir}
uv venv --python 3.12
uv pip install build123d
所有脚本均使用位于{baseDir}/.venv/bin/python的虚拟环境Python。所有输出均为JSON格式到标准输出。
bash
{baseDir}/.venv/bin/python {baseDir}/scripts/cad_generate.py \
--script from build123d import *
with BuildPart() as result:
Box(100, 60, 40) \
--format step \
--filename my_box
输出:{ success: true, artifactpath: ..., format: step, filesizebytes: N, boundingbox_mm: {...} }
bash
{baseDir}/.venv/bin/python {baseDir}/scripts/cad_measure.py \
--script from build123d import *
with BuildPart() as result:
Cylinder(10, 50)
输出:{ success: true, boundingboxmm: {...}, volumemm3: N, surfaceareamm2: N, centerofmassmm: {...}, facecount: N, edgecount: N }
bash
{baseDir}/.venv/bin/python {baseDir}/scripts/cad_section.py \
--script ... \
--plane XY \
--offset 5.0
输出:{ success: true, artifactpath: ..., plane: XY, offsetmm: 5.0 }
bash
{baseDir}/.venv/bin/python {baseDir}/scripts/cad_api.py
输出:包含基本体、操作、选择器、导出函数的JSON。如果需要了解可用功能,请先调用此命令。
检查多零件装配体的干涉、最小间隙和运动部件碰撞。
bash
{baseDir}/.venv/bin/python {baseDir}/scripts/cad_validate.py \
--script ... \
--mode full \
--min-clearance 1.0
模式:static(所有零件对之间的布尔交集),clearance(边界框间隙),sweep(在角度范围内旋转运动部件,检查碰撞),full(全部三种,默认)。
脚本必须定义parts = {name: solid, ...}字典。可选定义运动部件的sweeps列表:
python
from build123d import *
with BuildPart() as enclosure:
Box(100, 80, 50)
offset(amount=-3, openings=enclosure.faces().sort_by(Axis.Z)[-1:])
with BuildPart() as pcb:
with Locations((0, 0, 5)):
Box(60, 40, 2)
with BuildPart() as servo_arm:
with Locations((30, 0, 25)):
Box(5, 20, 3)
parts = {
enclosure: enclosure.part,
pcb: pcb.part,
servoarm: servoarm.part,
}
sweeps = [
{
name: servo_arm,
axis_origin: (30, 0, 25),
axis_direction: (0, 1, 0),
angle_start: -45,
angle_end: 45,
angle_step: 5,
},
]
输出:{ verdict: PASS|WARN|FAIL, staticinterference: {...}, clearance: {...}, sweptvolume: {...} }
扫掠体积导出到~/.openclaw/workspace/cad-output/swept_
所有单零件脚本必须通过BuildPart上下文将最终实体赋值给result:
python
from build123d import *
with BuildPart() as result:
Box(100, 60, 40)
fillet(result.edges().filter_by(Axis.Z), radius=5)
with Locations((0, 0, 40)):
CounterBoreHole(radius=5, counterboreradius=8, counterboredepth=3, depth=40)
对于验证脚本,定义parts字典(以及可选的sweeps列表)代替result。
所有尺寸单位为毫米。导出文件保存到~/.openclaw/workspace/cad-output/。
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 build123d-cad-1776086245 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 build123d-cad-1776086245 技能
skillhub install build123d-cad-1776086245
文件大小: 13.57 KB | 发布时间: 2026-4-14 14:15