Repository navigation
Releases
v2.0.0 Community | 社区版
swforge 2.0 Community
让 SolidWorks 少一点重复操作,多一点可复用成果。
本次重点是原生建模、可编辑尺寸与基础螺旋生成:增加台阶轴、七项原生特征、常用轮廓驱动尺寸、显式参数关联、特征树回读和基础净距检查。弹簧与等螺距绞龙交付无建模历史实体,调整输入后可另存重新生成。
适配 SolidWorks 2019 SP5 / 2025 SP5,具体实测范围见验证说明。工程图、GB、审图和批量交付保留公开 1.7 范围,加入必要兼容与可靠性修复。Community 继续采用 MIT;2.0 为社区版最后一次计划内功能更新;后续仍将分阶段推进 SolidWorks 2018–2026 兼容适配,并维护缺陷与安全问题,已验证范围将持续公布。
后续商业订阅侧重增强工程图、GB 规则更新、审图与批量任务管理,并逐步提供可编辑螺旋建模与下料复核;企业定制可提供图框规范、专用件库、产品生成及系统对接,具体交付另行说明。
所有生成结果仍需工程审核。后续兼容适配不增加已冻结的社区功能范围。
v1.7.0 Community | 社区版
swforge 1.7.0 Community / 社区版
从参数化零件、材料配色,到装配、工程图、BOM与PDF,让重复工程任务更容易复用和核对。
- 新增零件/装配变型、机械家族、多页图册与原生BOM流程。
- 随包A0–A4基础GB导向模板、第一角投影、标题字段与线宽检查。
- 保留Python、命令行和MCP接入;新增执行记录与交付文件新鲜度检查。
- 社区版MIT开源,允许商业使用;高级GB审图和工艺规则编排实现本次暂不发布。
升级提醒:MCP改为四入口,旧操作通过sw_invoke调用。仅SW2025 SP5实测,工程图仍需工程师审核,不声明完整GB认证。
English
Repeatable SolidWorks workflows for parameterized parts, materials/colors, assemblies, drawings, BOMs and PDFs.
- Part/assembly variants, mechanical families, drawing books and native BOM workflows.
- Packaged A0–A4 GB-oriented templates, first-angle projection, title fields and line-weight checks.
- Python, CLI and MCP access, execution records and artifact freshness checks.
- MIT Community source including commercial use. Advanced GB review and process-rule implementations are withheld from this release.
Migration: MCP now exposes four gateway entry points; invoke original operation names via sw_invoke. Native fixtures were tested on SW2025 SP5 only. Engineering review remains required; no full GB certification is claimed.
v1.4.1 — 图纸能交付了(粗糙度 + 公差 + 显式选面)
现在出的图,车间能直接用了
v1.3 出的是「看起来像工程图」;v1.4 出的是「车间能照着做」。
补上了表面粗糙度和尺寸公差 —— 这两样之前没有,图纸拿去做加工会被退回来。
pip install swforge
swforge selftest # 60 秒,13 项检查在你自己的机器上验证这一版新增
- 表面粗糙度符号 —— 支持贴到真实轮廓边(带引线),不是悬空的独立注记。
实测 3 个符号全部placement=edge、attached_entity_count=1,
视图移动 10mm 后符号跟随。 - 尺寸公差 —— 对称 / 双向 / 极限 / 配合(H7/g6)。偏差用毫米,
不改名义值;同值多尺寸时拒绝猜测。 - 显式配合选面(v1.4.1)—— 按持久面引用指定孔轴,不用半径猜。
实测轴套 + 轴同心配合:间隙 0 mm,平行误差 0 度,干涉 0 处。
演示视频
本 Release 附带 2 分 21 秒完整演示,从 SolidWorks 关闭状态开始,11 步全自动:
建模 → 国标材质 → GB 工程图 → 尺寸 → 粗糙度 → 公差 → PDF → 装配 → 配合 → 干涉。
诚实的限制
- 不能挖孔(
hole()抛 NotImplementedError)。FeatureCut在本机
SolidWorks 2025 SP5 上六种参数组合全部返回 null。可用revolve()
旋转环形轮廓造真孔,实测体积误差 0.00 mm³。 - 形位公差未做。
- 只在 SW 2025 SP5.0 实测。
v1.3.1 — 用 AI 驱动 SolidWorks
用 AI 驱动 SolidWorks 的开源工具
建模 → 国标材质 → 装配配合 → 精确干涉 → GB 工程图 → 剖视图 → BOM → 批量出图,每一步都回读验证。
pip install swforge
swforge selftest # 60 秒,在你自己的机器上验证这十项能力| 项 | 值 |
|---|---|
| 源码 | 6 563 行 Python,22 个模块 |
| 测试 | 172 项离线 + 10 项实机自检 + 双进程并发 |
| 接口 | MCP 22 个 · CLI 19 个 · Python 导出 56 项 |
下载
swforge.zip—— 源码压缩包,解压即用swforge-1.3.1-py3-none-any.whl—— 能直接pip install的安装包swforge-1.3.1.tar.gz—— sdist
做不到的(明说)
公差 / 粗糙度 / 形位公差未做 —— 图纸不能直接投产。
这是下一版(v1.4.0)的最高优先项。
v1.2.1 — 回读验证的 SolidWorks 自动化
swforge v1.2.1
用 Python / CLI / MCP 驱动本机 SolidWorks。建模、配国标材质、装配配合、查干涉、出 GB 工程图 —— 每一步都回读验证。
pip install "swforge[mcp,pdf]"
swforge selftest # 60 秒,在你自己的机器上验证这十项能力这个版本做了什么
-
release-check—— 检查「本地 / 标签 / PyPI 三方对得上吗」。
它存在的理由很具体:v1.1.0 标签打完后又改了源码,PyPI 上的包因此缺两个
用户可见的修复,README 说能用,装上其实是坏的。没有任何机制会提醒这件事。 -
剖视图 / 局部放大 ——
add_section_view()/add_detail_view()。
实测 3 个视图 → 6 个,生成「剖面视图 A-A」「剖面视图 B-B」「局部视图 I」。 -
BOM 表修正 —— 表其实一直插对了位置,看不见是因为插完没重新缩放。
顺带修了行里写组件实例名(垫片-3 ×3)而不是零件名(垫片 ×3)的问题。 -
双进程并发实测 —— 两个独立进程同时操作同一个 SolidWorks,
互相抢活动文档再抢回来,用读回体积 24000.0 mm³ 证明读到的是自己的文档。
标题不可靠——两个文档都可能叫「零件1」。
验证
158 项离线测试
selftest 10/10,125 秒
双进程并发,两侧全过
做不到的(明说)
公差 / 粗糙度 / 形位公差 —— 没有它,图纸不能直接投产。
这是目前最大的缺口,也是下一版的重点。
swforge v0.9.0 — batch drawings + capability probe
swforge v0.9.0
Two new commands
*\swforge batch * — a folder of parts becomes a stack of GB-framed drawings.
\
[1/5] ✓ 垫块.SLDPRT 尺寸 6(总尺寸 4) +PDF 3.0s
[2/5] ✓ 支架.SLDPRT 尺寸 24(总尺寸 6) +PDF 3.4s
[3/5] ✓ 法兰.SLDPRT 尺寸 6(总尺寸 6) +PDF 3.1s
[4/5] ✓ 轴套.SLDPRT 尺寸 6(总尺寸 6) +PDF 3.1s
[5/5] ✓ 连接板.SLDPRT 尺寸 6(总尺寸 4) +PDF 3.1s
合计 5 个模型 成功 5 失败 0 跳过 0 PDF 5
耗时 15.7 秒
\\
*\swforge capabilities --api* — reflects over the installed Interop library and tells
you in 0.43 s whether your SolidWorks can run this.
\
程序集 33.5.0.53
可用率 28/28
全部可用 —— 本机 SolidWorks 支持 swforge 的完整功能
\\
Also in this release
- Overall dimensions now work on revolved parts (flange 120/60, bushing 40/24).
Vertices → edge endpoints → single-entity dimensions, because a cylinder's drawing
view has no vertices and its edges are closed curves. - CI on Python 3.10–3.13: 106 offline tests, package build, sdist content check,
and a guard that fails if a test touches SolidWorks without the \sw\ marker. - README gained a "Not yet" section and a three-layer verification boundary table.
Fixed
- \produce()\ returned \err=1\ when the target drawing already existed (previous
drawing still open, file locked) - \�dd_dimensions(overall=True)\ referenced an undefined variable
- sdist was missing \docs/\ and \demo/\
- batch failed from the 5th part on after hitting SolidWorks' 8-document cap
Numbers
| v0.8.0 | v0.9.0 | |
|---|---|---|
| Tests | 124 | 138 (106 offline + 32 live) |
| Modules | 14 | 16 |
| CLI commands | 11 | 13 |
| sdist files | 41 | 65 |
Honest boundary
Verified on SolidWorks 2025 SP5.0 only. 2019–2024 untested — the --api\ probe tells
you what your machine supports, but a method existing is not the same as its behaviour
matching. CI has no SolidWorks; there is no remote CAD evidence.
Full changelog: CHANGELOG.md
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()无参调用带参方法)