CAD Agent技能使用说明
2026-03-29
新闻来源:网淘吧
围观:9
电脑广告
手机广告
CAD代理
为您的AI代理配备用于CAD工作的"眼睛"。
描述
CAD代理是一个渲染服务器,能让AI代理看到它们正在构建的内容。发送建模命令 → 接收渲染图像 → 进行视觉迭代。

适用场景:设计可3D打印的零件、参数化CAD、机械设计、build123d建模
架构
关键要点:所有CAD逻辑都在容器内运行。您(代理)只需:
- 通过HTTP发送命令
- 查看返回的图像
- 决定下一步操作
YOU (agent) CAD AGENT CONTAINER
───────────── ───────────────────
Send build123d code → Executes modeling
← Returns JSON status
Request render → VTK renders the model
← Returns PNG image
*Look at the image*
Decide: iterate or done
切勿在容器外进行STL操作、网格处理或渲染。容器处理所有事情——您只需下达命令并观察。
设置
1. 克隆仓库
git clone https://github.com/clawd-maf/cad-agent.git
cd cad-agent
2. 构建Docker镜像
docker build -t cad-agent:latest .
或使用docker-compose:
docker-compose build
3. 运行服务器
# Using docker-compose (recommended)
docker-compose up -d
# Or using docker directly
docker run -d --name cad-agent -p 8123:8123 cad-agent:latest serve
4. 验证安装
curl http://localhost:8123/health
# Should return: {"status": "healthy", ...}
Docker-in-Docker注意事项:在嵌套容器环境(例如Clawdbot沙箱)中,主机网络可能无法正常工作——
curl localhost:8123即使服务器已绑定到0.0.0.0:8123,此命令也会失败。请改用docker exec cad-agent python3 -c "..."命令。在普通Docker主机上,localhost访问可正常工作。
工作流程
1. 创建模型
curl -X POST http://localhost:8123/model/create \
-H "Content-Type: application/json" \
-d '{
"name": "my_part",
"code": "from build123d import *\nresult = Box(60, 40, 30)"
}'
2. 渲染与查看
# Get multi-view (front/right/top/iso)
curl -X POST http://localhost:8123/render/multiview \
-d '{"model_name": "my_part"}' -o views.png
# Or 3D isometric
curl -X POST http://localhost:8123/render/3d \
-d '{"model_name": "my_part", "view": "isometric"}' -o iso.png
查看图像。看起来正确吗?如果不正确,请修改并重新渲染。
3. 迭代
curl -X POST http://localhost:8123/model/modify \
-d '{
"name": "my_part",
"code": "result = result - Cylinder(5, 50).locate(Pos(20, 10, 0))"
}'
# Re-render to check
curl -X POST http://localhost:8123/render/3d \
-d '{"model_name": "my_part"}' -o updated.png
4. 导出
curl -X POST http://localhost:8123/export \
-d '{"model_name": "my_part", "format": "stl"}' -o part.stl
端点
| 端点 | 功能说明 |
|---|---|
POST /model/create | 运行build123d代码,创建模型 |
POST /model/modify | 修改现有模型 |
GET /model/list | 列出会话中的模型 |
GET /model/{name}/measure | 获取尺寸 |
POST /render/3d | 3D着色渲染(VTK) |
POST /render/2d | 2D技术图纸 |
POST /render/multiview | 四视图组合图 |
POST /export | 导出STL/STEP/3MF格式 |
POST /analyze/printability | 检查可打印性 |
build123d 速查表
from build123d import *
# Primitives
Box(width, depth, height)
Cylinder(radius, height)
Sphere(radius)
# Boolean
a + b # union
a - b # subtract
a & b # intersect
# Position
part.locate(Pos(x, y, z))
part.rotate(Axis.Z, 45)
# Edges
fillet(part.edges(), radius)
chamfer(part.edges(), length)
重要提示
- 不要绕过容器。不使用matplotlib,不使用外部STL库,不进行网格篡改。
- 渲染是你的眼睛。变更后务必请求渲染。
- 视觉化迭代。关键在于你能看到正在构建的内容。
设计文件安全性
该项目具备防止意外提交CAD输出文件的安全措施:
.gitignore屏蔽 *.stl、*.step、*.3mf 等文件- 预提交钩子会拒绝设计文件
- 用户的设计文件保留在本地,永远不会被版本控制
链接
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~