Fusion360内置脚本 → 本地FastAPI中转 → 阿里云通义千问API → 标准化铣削/钻孔/型腔切削参数 → 自动弹窗展示
- Overview
- System Architecture
- Features
- Quick Start
- Project Structure
- API Reference
- Built-in Knowledge Base
- Configuration
- Fusion360 Integration
- Troubleshooting
- Changelog
- License
A production-ready CNC process recommendation system that bridges Autodesk Fusion360 CAM with Alibaba Cloud Tongyi Qianwen (通义千问) LLM API. The system provides AI-generated cutting parameters (tool, spindle speed, feed rate, depth of cut) for machining operations directly inside the Fusion360 CAM workspace.
| Decision | Rationale |
|---|---|
| ☁️ Cloud API only | No local GPU required; runs on Intel Ultra5 integrated graphics laptops |
🔧 Fixed model qwen2.5-14b-instruct |
Stable, cost-effective, Chinese-optimized |
| 📐 Fixed output format | `Tool |
🌡️ temperature=0.1 |
Minimizes hallucination; parameters are deterministic |
| 📚 Embedded knowledge base | 6 features × 4 materials with shop-floor-validated baseline params |
| ⚡ Zero middleware | No Redis, no database, no Docker — Python + FastAPI only |
┌──────────────────────────────────────────────────────────────┐
│ Autodesk Fusion360 │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ fusion360_cam_ai.py (内置Python脚本) │ │
│ │ ┌─────────────┐ ┌──────────┐ ┌────────────────────┐ │ │
│ │ │ 下拉框选择 │ │ 查询按钮 │ │ 结果弹窗展示 │ │ │
│ │ │ 特征·材料·机床│ │ →调用API │ │ 刀具|S|F|ap │ │ │
│ │ └─────────────┘ └────┬─────┘ └────────────────────┘ │ │
│ └────────────────────────┼────────────────────────────────┘ │
└───────────────────────────┼───────────────────────────────────┘
│ HTTP POST /get_craft
▼
┌──────────────────────────────────────────────────────────────┐
│ Windows 11 本机 (D:\CAM_CLOUD_API) │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ FastAPI 中转服务 (cam_cloud_api.py :8000) │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ 1.参数校验 │→│ 2.拼装Prompt │→│ 3.调用AI API │ │ │
│ │ │ 材料/特征枚举 │ │ 知识库前缀 │ │ DashScope SDK │ │ │
│ │ └──────────────┘ └──────────────┘ └──────┬───────┘ │ │
│ └──────────────────────────────────────────────┼─────────┘ │
└─────────────────────────────────────────────────┼─────────────┘
│ HTTPS
▼
┌──────────────────────────────────────────────────────────────┐
│ 阿里云 DashScope 云端 │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ qwen2.5-14b-instruct (temperature=0.1) │ │
│ │ → 生成标准化切削参数 │ │
│ └────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
- 🔗 End-to-end pipeline: Fusion360 script → local FastAPI → cloud AI → formatted parameters
- 🎯 Fixed output format:
刀具型号 | 主轴转速S | 进给速度F | 切削深度ap - 📚 Built-in knowledge base: 6 machining features × 4 materials with validated baseline data
- 🌡️ Low-temperature inference:
temperature=0.1ensures deterministic, stable outputs - 🔒 Offline fallback: Knowledge base lookup works without internet / API calls
- 📝 Fully commented code — every function, class, and complex block
- 🧹 Clean variable naming —
craft_params,VALID_MATERIALS,CRAFT_KNOWLEDGE_BASE - 🛡️ Input validation — Pydantic models with enum constraints
- 📊 Structured logging — timestamped, level-tagged log output
- 🔍 Health check endpoint — API connectivity verification
- 🚀 One-click Windows startup —
start_service.batwith auto-dependency check - 🤖 Auto-start support — VBScript for silent boot-time launch
- 📖 Auto-generated API docs — Swagger UI at
http://127.0.0.1:8000/docs
- Windows 11 (primary target; works on Win10+)
- Python 3.10+ (download)
- Alibaba Cloud DashScope API Key (get one)
- Autodesk Fusion360 with CAM workspace
mkdir D:\CAM_CLOUD_API
cd D:\CAM_CLOUD_API
# Clone or copy all project files into this directory, then:
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/Edit start_service.bat line 18:
set DASHSCOPE_API_KEY=sk-YOUR-REAL-API-KEY-HERE# Double-click:
start_service.bat
# Or command line:
python cam_cloud_api.pyYou should see:
模型: qwen2.5-14b-instruct | 温度: 0.1 | 端口: 8000
Uvicorn running on http://0.0.0.0:8000
# Health check
Invoke-RestMethod http://127.0.0.1:8000/health
# Test AI query
$body = '{"feature":"平面铣削","material":"6061铝","machine":"三轴立式加工中心"}'
Invoke-RestMethod -Uri http://127.0.0.1:8000/get_craft -Method Post -Body $body -ContentType "application/json"- Tools → Scripts & Add-Ins → Create → Python
- Name it
CAM_AI_Craft - Paste
fusion360_cam_ai.pycontents - Save → Run
D:\CAM_CLOUD_API\
├── cam_cloud_api.py # FastAPI relay service (core backend)
├── fusion360_cam_ai.py # Fusion360 Python script (client)
├── requirements.txt # Python dependency manifest
├── start_service.bat # Windows one-click launcher
├── auto_start.vbs # Silent auto-start script for boot
├── README.md # This file
├── CHANGELOG.md # Version history
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
http://127.0.0.1:8000
Generate AI-recommended cutting parameters.
Request Body:
{
"feature": "平面铣削",
"material": "6061铝",
"machine": "三轴立式加工中心"
}| Field | Type | Required | Options |
|---|---|---|---|
feature |
string | ✅ Yes | 平面铣削, 型腔加工, 键槽加工, 钻孔, 攻丝, 曲面精加工 |
material |
string | ✅ Yes | 6061铝, 45#钢, 304不锈钢, H62黄铜 |
machine |
string | No (default: 三轴立式加工中心) |
三轴立式加工中心, 数控铣床, 钻攻中心, 五轴加工中心, 龙门铣床 |
Response 200 OK:
{
"craft_params": "Φ63端铣刀(5刃) | S6000 | F1200 | ap1.0",
"feature": "平面铣削",
"material": "6061铝",
"machine": "三轴立式加工中心",
"status": "ok"
}Error Responses:
| Code | Detail | Cause |
|---|---|---|
400 |
不支持的材料: 'xxx' | Material not in knowledge base |
400 |
不支持的特征: 'xxx' | Feature not in knowledge base |
401 |
API Key 认证失败 | Invalid/expired DashScope API key |
502 |
DashScope API 返回错误 | Cloud API downstream failure |
500 |
AI服务调用失败 | Network / SDK exception |
List full knowledge base (no API call).
Look up baseline parameters offline.
Service health + API connectivity check.
Visit http://127.0.0.1:8000/docs for the auto-generated Swagger UI.
| Material | Face Milling 平面铣削 |
Pocket 型腔加工 |
Keyway 键槽加工 |
Drilling 钻孔 |
Tapping 攻丝 |
Surface Finish 曲面精加工 |
|---|---|---|---|---|---|---|
| 6061 Al | Φ63端铣刀 S6000 F1200 ap1.5 |
Φ12立铣刀 S8000 F1500 ap1.0 |
Φ8键槽铣刀 S5000 F800 ap0.5 |
Φ6麻花钻 S4000 F300 |
M6丝锥 S800 F800 |
R5球刀 S10000 F2000 ap0.2 |
| 45# Steel | Φ63端铣刀 S2500 F500 ap1.0 |
Φ12立铣刀 S3500 F600 ap0.5 |
Φ8键槽铣刀 S2500 F400 ap0.3 |
Φ6麻花钻 S1800 F150 |
M6丝锥 S300 F300 |
R5球刀 S5000 F800 ap0.15 |
| 304 SS | Φ63端铣刀(涂层) S1200 F250 ap0.5 |
Φ12立铣刀(AlTiN) S2000 F300 ap0.3 |
Φ8键槽铣刀(涂层) S1500 F200 ap0.2 |
Φ6含钴钻 S800 F80 |
M6含钴丝锥 S150 F150 |
R5球刀(涂层) S3500 F500 ap0.1 |
| H62 Brass | Φ63端铣刀 S5000 F1000 ap1.5 |
Φ12立铣刀 S7000 F1200 ap1.0 |
Φ8键槽铣刀 S4000 F600 ap0.5 |
Φ6麻花钻 S3500 F250 |
M6丝锥 S600 F600 |
R5球刀 S8000 F1500 ap0.2 |
💡 These are shop-floor-validated starting parameters for carbide tooling on 3-axis VMCs. Always adjust based on your specific setup, tool holder, coolant, and rigidity conditions.
| Parameter | Location | Default | Description |
|---|---|---|---|
DASHSCOPE_API_KEY |
cam_cloud_api.py:40 or env var |
sk-xxx... |
Alibaba Cloud DashScope API key |
MODEL_NAME |
cam_cloud_api.py:44 |
qwen2.5-14b-instruct |
AI model ID |
TEMPERATURE |
cam_cloud_api.py:45 |
0.1 |
LLM sampling temperature |
MAX_TOKENS |
cam_cloud_api.py:46 |
200 |
Max output tokens |
TOP_P |
cam_cloud_api.py:47 |
0.1 |
Nucleus sampling parameter |
| Host/Port | cam_cloud_api.py:265 |
0.0.0.0:8000 |
FastAPI server binding |
API_BASE_URL |
fusion360_cam_ai.py:39 |
http://127.0.0.1:8000 |
Fusion360 → API endpoint |
Fusion360 scripts are stored at:
%APPDATA%\Autodesk\Autodesk Fusion 360\API\Scripts\CAM_AI_Craft\
- In Fusion360: Tools → Scripts & Add-Ins
- Click Create → Python
- Name:
CAM_AI_Craft - Replace default content with
fusion360_cam_ai.py - Save & Run
┌─────────────────────────────────────────┐
│ ⭐ 云端AI工艺参数推荐系统 ⭐ │
├─────────────────────────────────────────┤
│ 加工特征: [▼ 平面铣削 ] │
│ 工件材料: [▼ 6061铝 ] │
│ 机床类型: [▼ 三轴立式加工中心 ] │
├─────────────────────────────────────────┤
│ ✅ Φ63端铣刀(5刃) | S6000 | F1200 | │
│ ap1.0 ← AI结果 │
├─────────────────────────────────────────┤
│ [🔍 查询工艺参数] ← 云端AI (收费) │
│ [📖 查看知识库基准] ← 离线 (免费) │
└─────────────────────────────────────────┘
| Symptom | Probable Cause | Fix |
|---|---|---|
ModuleNotFoundError: dashscope |
Missing dependency | pip install -r requirements.txt |
AuthenticationError |
Wrong API key | Check cam_cloud_api.py:40 |
| Connection refused in Fusion360 | Service not running | Double-click start_service.bat first |
| Port 8000 occupied | Another process | netstat -ano | findstr :8000 → taskkill /PID N /F |
| Script error in Fusion360 | Paste truncated | Re-copy full fusion360_cam_ai.py |
| AI output malformed | Rare model variance | Use offline KB button; or re-query |
| Firewall blocks Python | Windows Defender | Allow python.exe in firewall settings |
# 1. Python version
python --version
# 2. Dependencies
python -c "import fastapi, uvicorn, dashscope, pydantic; print('OK')"
# 3. Service health
Invoke-RestMethod http://127.0.0.1:8000/health
# 4. AI connectivity
Invoke-RestMethod http://127.0.0.1:8000/get_craft -Method Post `
-Body '{"feature":"平面铣削","material":"6061铝","machine":"三轴立式加工中心"}' `
-ContentType "application/json"This project is licensed under the MIT License — see the LICENSE file for details.
- Alibaba Cloud DashScope — Tongyi Qianwen LLM API
- Autodesk Fusion360 — Python API for CAM automation
- FastAPI — High-performance Python web framework
- Uvicorn — Lightning-fast ASGI server