Repository navigation
swforge v0.8.0 — first public release
swforge v0.8.0 — first public release
Drive SolidWorks from Python / CLI / MCP with verification at every step.
Install
git clone https://github.com/mwdandoms/swforge.git
cd swforge
python -m pip install -e ".[mcp,pdf]"Requires Windows + SolidWorks (verified on 2025 SP5.0) + Python 3.10+.
What makes it different
Most SolidWorks automation projects focus on letting an AI call SolidWorks.
This one focuses on whether the result is actually correct:
| Problem | This project's answer |
|---|---|
| GB material assignment fails silently — density falls back to 1000 kg/m3 (water), mass off by 7.85x | Ships a 20-grade GB material library, auto-deployed into the SolidWorks scan path |
| Drawings come out in inches with no frame | Picks the Chinese gb_<paper>.drwdot template: frame, title block, material, weight, scale |
| Interference checks return nothing (assembly API returns 0 for a known 500 mm3 overlap) | Part-level boolean intersection, exact to 500.000 mm3 |
| Your build "succeeds" but nothing is verified | Body count, envelope, per-face colors, material, mass and volume are all read back |
Numbers
- 4,283 lines of Python across 14 modules
- 124 tests (95 offline + 29 live)
- 22 MCP tools, 41 public exports, 20 GB material grades
Known limitations
- Verified only on SolidWorks 2025 SP5.0 — 2019-2024 untested
- Generated
.SLDPRTuses the current format; older SolidWorks cannot open them - Tolerances and surface finish are not generated (deliberate: no invented engineering requirements)
- The assembly-level interference API is unusable on this machine; interference goes through part-level booleans
See docs/limitations.md for the full list, and docs/pitfalls.md for the 10 COM traps
this project hit and documented.
[0.8.0] - 2026-11-03
新增
- 总尺寸标注
dims.py:按视图可见顶点极值显式生成总长/总高
(InsertModelAnnotations4拿不到总尺寸,且会跨视图去重) - 配合
mates.py:同心 / 重合,自动选面(等径圆柱、平行平面),C# 早期绑定实现 - 精确干涉
interference.py:实体布尔求交,实测 500.000 mm³ - 测试 111 → 124 项
修复
- 干涉求交返回错误码 1:
swBodyOperationNonApiBody—— 文档体不是 API 临时体,
需先Copy2(False) - 配合判据:
swAddMateError_NoError = 1(不是 0) - 装配坐标单位:
AddComponent5内部要米,此前把毫米当米传,零件被放到 60 米外 - 工程图模板选型:改为按年份扫描 + 中文
gb_<纸张>.drwdot优先 _ensure_mm_units读不到单位值(_value()无参调用带参方法)