agentleFS
LTGOzLTGOz/solidworks-agent-skill/SKILL.md

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

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. wzyn20051216/solidworks-automation-skill★ 1.9ksame name
    2. delancy827/solidworks-skills★ 130same name
    3. 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.

The file

Files
SKILL.md

SolidWorks 2023 本机自动化建模(配方驱动 · 实测打通)

把"描述物体 → JSON 建模配方 → SolidWorks 直接画出"封装成一条命令,附程序化几何验证。

仓库布局

路径说明
sw_bridge.py核心桥:配方驱动,一条命令完成 建模→保存→导出→断言
stl_slicer.pySTL 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/输出目录)

环境前提(缺一不可)

  1. Windows + 正版 SolidWorks 2023 正在运行。COM 只能附着交互式会话(GetObject),不能无头,也不能由脚本拉起(COM 拉起的实例注册不了 ROT,见 api-pitfalls §13)。
  2. Python 3.10+,pip install -r requirements.txt(pywin32 / trimesh / manifold3d / numpy / pillow)。
  3. 国标中文版模板路径已内置默认值;英文版或自定义模板复制 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   # 切片看截面

标准工作流

  1. 写配方 JSON(语法与模板见 references/recipe-cookbook.md)
  2. 执行:python sw_bridge.py --recipe-file recipes/xxx.json
  3. 验证:配方内置 verify 断言(水密/体积/包围盒/golden IoU),失败即整条失败;再用 stl_slicer.py 看截面
  4. 出图:多个 view op 导出多角度 PNG;fmt: step 给下游
  5. 结构审查(产品类零件):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/装配/网格导入
verifytrimesh 断言层(水密/体积/包围盒/golden IoU)

执行期自动冻结图形刷新/特征树(性能包裹),收口统一 ForceRebuild3+ForceRebuildAll。

硬规则速查(完整版见 references/api-pitfalls.md)

  1. API 长度单位一律米,配方里写 mm(桥自动换算)。
  2. FeatureRevolve2 是 20 参;类型库生成的 4/5/7 参版本全错。
  3. 晚绑定下 Callout/ExportData 必须传 VARIANT(VT_DISPATCH, None);CreateSpline2 点数组必须 VT_ARRAY|VT_R8。
  4. 进出草图都用 InsertSketch(True)(Toggle)。
  5. 中文本地化名:前视基准面/草图1/*等轴测(config 可切英文环境候选)。
  6. 复杂特征(>12 参)失败 → 终极兜底:SW 录宏 → RunMacro2 回放。
  7. GetEquationMgr 是 propget-only,须按 dispid 强制 PROPERTYGET(见 api-pitfalls §12)。
  8. 复杂 API 签名先查 SW 安装的类型库(makepy)或录宏,不要凭记忆猜。

版本兼容性说明

本包在 SW2023 中文国标版实测打通(含 dispid 66286、ProgID .31、20 参 FeatureRevolve2 等版本相关细节)。 其他 SW 版本核心流程通用,但版本相关常量需按 api-pitfalls §12 的方法重新查证(makepy 类型库/录宏)。

已实测 / 未实测边界

  • ✅ 拉伸、旋转、样条、矩形/圆/圆弧、切除、圆角、倒角、装配体加组件、GV/方程式、STL/STEP/IGS/PNG 导出、网格导入、几何断言
  • ❌ 扫描/放样/阵列/配合未实测(理论同路数,签名先查类型库或录宏)

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.