solidworks-automation
Skill1 starsChanged 2 months agoMITView on GitHub
驱动本机 SolidWorks 2023 自动化参数化建模的实战能力包:JSON 配方驱动 sw_bridge.py(草图/拉伸/旋转/切除/ 圆角/倒角/装配/多视图/全局变量/保存/导出 STL·STEP·IGS·PNG)、trimesh 几何断言验证、STL 切片确定性验证。当用户要建模/画零件/生成 3D 模型/出 STL·STEP、提到 SolidWorks、SW2023、参数化建模、草图、 拉伸、旋转、切除、装配体、sw_bridge、建模配方、recipe、SldWorks COM、ModelDoc2 时使用。 反触发:纯 CAD 理论问答、其他 CAD 软件(AutoCAD/FreeCAD)、查 SW API 文档。
- Installs packages
3 other projects use a version of this.
Adopted by
Most recently taken up by
- wzyn20051216/solidworks-automation-skilltheir own version, first seen Nov 4, 2026
- zunyiqingfeng-code/skillstheir own version, first seen Aug 21, 2026
- delancy827/solidworks-skillstheir own version, first seen Jun 4, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- wzyn20051216/solidworks-automation-skill★ 1.9ksame name
- delancy827/solidworks-skills★ 130same name
- zunyiqingfeng-code/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
- sw-dfm-injectionSkill
- sw-dfm-protoSkill
The file
Files
SolidWorks 2023 本机自动化建模(配方驱动 · 实测打通)
把"描述物体 → JSON 建模配方 → SolidWorks 直接画出"封装成一条命令,附程序化几何验证。
仓库布局
| 路径 | 说明 |
sw_bridge.py | 核心桥:配方驱动,一条命令完成 建模→保存→导出→断言 |
stl_slicer.py | STL ASCII 切片验证(程序化确认轮廓/孔/槽,不靠读图) |
recipes/ | 现成配方示例(含全链路自检 recipe_best_practices_test.json) |
dfm_check.py + rules/ | 产品结构 DFM 检查器:注塑(16条)/3D打印(14条)双工艺量化规则库,设计参数表体检 + 配方 lint |
skills/sw-dfm-injection/ | 分支技能:注塑 DFM(DVT/量产,壁厚/拔模/卡扣/Boss/筋/倒扣量化规则) |
skills/sw-dfm-proto/ | 分支技能:3D 打印手板 DFM(EVT,最小特征/悬空/间隙/排液孔量化规则) |
references/api-pitfalls.md | 血泪教训全量:COM/签名/VARIANT/EquationMgr/ROT 坑,写新能力前必读 |
references/recipe-cookbook.md | 配方语法详解 + 模板 + 多规格/断言用法 |
references/industry-best-practices.md | 行业范式调研浓缩 + 后续改造清单 |
docs/case_mcp1085_box.md | 实战交付案例:两层水管检测盒 |
config.example.json | 机器相关配置模板(模板路径/ProgID/输出目录) |
环境前提(缺一不可)
- Windows + 正版 SolidWorks 2023 正在运行。COM 只能附着交互式会话(
GetObject),不能无头,也不能由脚本拉起(COM 拉起的实例注册不了 ROT,见 api-pitfalls §13)。 - Python 3.10+,
pip install -r requirements.txt(pywin32 / trimesh / manifold3d / numpy / pillow)。 - 国标中文版模板路径已内置默认值;英文版或自定义模板复制
config.example.json为config.json修改。
快速自检
python sw_bridge.py --demo block # 建方块 + 导出 + 几何断言一条龙
python sw_bridge.py --demo vase # 样条旋转曲面
python stl_slicer.py --stl demo_output/demo_block.STL --level 5 # 切片看截面标准工作流
- 写配方 JSON(语法与模板见
references/recipe-cookbook.md) - 执行:
python sw_bridge.py --recipe-file recipes/xxx.json - 验证:配方内置
verify断言(水密/体积/包围盒/golden IoU),失败即整条失败;再用stl_slicer.py看截面 - 出图:多个
viewop 导出多角度 PNG;fmt: step给下游 - 结构审查(产品类零件):
python dfm_check.py --design 参数表.json --process both——注塑/3D打印双工艺 DFM 体检,FAIL 即门禁不通过;分支技能见skills/
配方 op 一览(完整参数见 cookbook)
| op | 说明 |
new_part / new_assembly / open | 文档操作 |
sketch / sketch_end / centerline / spline / line / rect / circle / arc | 草图(mm) |
extrude / revolve / cut / fillet / chamfer | 特征(失败自动重试降级) |
set_global_variable / add_equation | 全局变量/方程式 → 同型号多规格走 GV 变异 |
view / save / export / add_component / import_mesh | 视图/保存/导出 stl·png·step·iges/装配/网格导入 |
verify | trimesh 断言层(水密/体积/包围盒/golden IoU) |
执行期自动冻结图形刷新/特征树(性能包裹),收口统一 ForceRebuild3+ForceRebuildAll。
硬规则速查(完整版见 references/api-pitfalls.md)
- API 长度单位一律米,配方里写 mm(桥自动换算)。
FeatureRevolve2是 20 参;类型库生成的 4/5/7 参版本全错。- 晚绑定下 Callout/ExportData 必须传
VARIANT(VT_DISPATCH, None);CreateSpline2点数组必须VT_ARRAY|VT_R8。 - 进出草图都用
InsertSketch(True)(Toggle)。 - 中文本地化名:前视基准面/草图1/*等轴测(config 可切英文环境候选)。
- 复杂特征(>12 参)失败 → 终极兜底:SW 录宏 →
RunMacro2回放。 GetEquationMgr是 propget-only,须按 dispid 强制 PROPERTYGET(见 api-pitfalls §12)。- 复杂 API 签名先查 SW 安装的类型库(makepy)或录宏,不要凭记忆猜。
版本兼容性说明
本包在 SW2023 中文国标版实测打通(含 dispid 66286、ProgID .31、20 参 FeatureRevolve2 等版本相关细节)。
其他 SW 版本核心流程通用,但版本相关常量需按 api-pitfalls §12 的方法重新查证(makepy 类型库/录宏)。
已实测 / 未实测边界
- ✅ 拉伸、旋转、样条、矩形/圆/圆弧、切除、圆角、倒角、装配体加组件、GV/方程式、STL/STEP/IGS/PNG 导出、网格导入、几何断言
- ❌ 扫描/放样/阵列/配合未实测(理论同路数,签名先查类型库或录宏)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

