Skip to content
Automation
Skill

/solidworks-automation-skill

SolidWorks CAD 自动化技能,优先覆盖经验证的零件、孔槽、装配、工程图、导出和交付复核;所有能力等级以 capabilities.yaml 为准,未验证能力必须走人工复核。

From plugin
solidworks-automation-skill
1.6k1 skill

Claude Code

$ npx -y skills add wzyn20051216/solidworks-automation-skill --skill solidworks-automation-skill --agent claude-code

SKILL.md

solidworks-automation-skill.SKILL.md
name: solidworks-automation
description: "SolidWorks CAD 自动化技能,优先覆盖经验证的零件、孔槽、装配、工程图、导出和交付复核;所有能力等级以 capabilities.yaml 为准,未验证能力必须走人工复核。"
metadata: { "openclaw": { "homepage": "https://github.com/wzyn20051216/solidworks-automation-skill", "os": ["win32"], "requires": { "anyBins": ["python", "py"] } } }

SolidWorks 自动化技能

快速开始

环境要求

  • Windows 系统;原生 SolidWorks 操作以 SolidWorks 2026 为支持与验收目标,开放格式无头写入不要求安装 CAD 软件
  • Python 3.10+;原生 Windows CAD 自动化另需 `pywin32` / `comtypes`
  • MCP/工具化调用需要 `mcp` / `pydantic`
  • 工程图最终交付审查需要 `PyMuPDF`;它从 SolidWorks 导出 PDF 回读实际尺寸文字边界,已包含在 `requirements.txt`
  • 处理 GLB/GLTF/OBJ/STL 网格参考模型时,可能还需要 `trimesh` / `pygltflib` / `numpy` / `Pillow`
  • 如果通过 OpenClaw 使用,确保技能目录位于 `~/.openclaw/skills/solidworks-automation/` 或 `~/.agents/skills/solidworks-automation/`

入口自检

所有代理在执行 SolidWorks 自动化前,先运行技能自检:

python SKILL_DIR/scripts/sw_preflight.py

桌面端或 CLI 执行前建议先运行环境诊断:

python SKILL_DIR/scripts/cad_studio.py doctor

`capabilities.yaml` 是 Skill、MCP、队列和 UI 共用的能力唯一真源。能力等级为 `verified`、`pilot`、`reference_only` 或 `not_implemented`;后两者不得作为无人值守交付。该清单还维护 Python、C# PIA/Add-in、原生 C++、SWBasic、OCCT 和外部求解器的原子操作路由;执行前可用 `python scripts/backend_router.py --list` 查询,规则见 `references/language-backend-routing.md`。

多入口与多后端

  • CAD Studio 与 Skill/CLI/MCP 是平级入口,共用 Automation Job、NeutralCadDocument、Preview Manifest、Evidence Graph 和能力清单。
  • 检测不到 SolidWorks/AutoCAD 时,只阻断 `SLDPRT/SLDASM/SLDDRW/DWG` 等原生格式;开放格式任务优先路由到 `headless_open_format_writing`。
  • 需要设计规则审查或丝杠/皮带电机扭矩初筛时,读取 `references/design-rule-check.md` 和 `references/drive-sizing.md`,以用户提供或经验证采集的中性文档为输入;缺失证据标为 `review_required`,结果必须由工程师复核。
  • 需要识别钻孔面板孔位或规划图纸候选时,读取 `subskills/solidworks-engineering-drawing/references/drilling-panel-gdt.md`;孔型、基准和公差不得凭几何猜定,候选规格不得冒充已验证工程图。
  • 用户要求基准、复合公差框或 GD&T 自动落图时,读取 `subskills/solidworks-engineering-drawing/references/native-gdt.md`。已有图纸先用 `scripts/sw_gdt_copy.py --source 图纸.slddrw --inspect` 查明目标,再写新副本;从模型新出图使用现有 MCP `solidworks_generate_drawing` 或 `scripts/sw_drawing_package.py`,提供结构化尺寸、基本尺寸、基准及单框/复合框要求。SW2026 保存重开核验原生关联、全部层和基准材料修饰,源文件保留,结果需目视复核;旧自由文字不猜测落图。
  • 公共基准、子基准组、投影公差带、轮廓偏置、CZ/SZ、局部范围和其他高级 GD&T,继续读取 `subskills/solidworks-engineering-drawing/references/gdt-extended-options.md`,通过同一工具提交结构化成员与 `options`;每个成员都须核对,写入后保存重开核验全部新语义。
  • 要提取已保存模型的已显示尺寸公差时,使用 `scripts/sw_tolerance_extract.py`;它只读当前配置,结果不覆盖隐藏尺寸或其他配置,角度、装配和图纸读取仍需验证。
  • 需要按属性批量改名时,先用 `scripts/sw_file_rename.py` 生成只读预览;受限独立零件可用 `scripts/sw_rename_copy.py`,单配置嵌套装配可用 `scripts/sw_assembly_rename.py` 在新目录创建副本并重开核验。源文件及外部使用位置不改;图纸、Toolbox、多配置及其他未验证引用仍受阻断,详见 `references/rename-preview.md`。
  • 需要链轮外观或几何演示时,读取 `references/sprocket.md` 并使用 `scripts/sw_sprocket.py` 在新建空零件中创建近似实体;此模型未验证链条啮合或制造要求,不能作为生产级标准链轮。
  • 需要开放端等螺距圆线弹簧实体时,读取 `references/spring.md` 并使用 `scripts/sw_spring.py`;输入高度是螺旋中心线轴向行程而非实体自由高度,材料、端部和工程性能必须复核。
  • 无头写入使用 `scripts/headless_cad_writer.py`;OCCT/OCP 隔离进程真实写入 STEP、IGES、BREP、STL、OBJ、GLB,二维后端写入 DXF、SVG、PDF、PNG,并生成几何与 SHA-256 证据。
  • DXF 交付会额外生成 `preview_scene`;已有 DXF 可通过 `python scripts/cad_studio.py preview-dxf --input drawing.dxf --output drawing.scene.json` 或 MCP `cadstudio_build_dxf_preview_scene` 转成受限 PreviewScene。该命令只读白名单实体并拒绝覆盖旧文件。
  • OCCT 当前覆盖盒体、圆柱、布尔合并、圆柱孔切除、直纹/受限平滑 Loft、直线/单圆弧 Sweep、闭壳 Knit 和开放面 Thicken;复杂路径、自交偏置或缺少 OCP 运行时时保持 `blocked`。禁止通过改扩展名或空文件伪造支持。
  • `delivery-preview` 只允许显示当前任务真实产物;固定样例必须标记 `demo-showcase` 与 `isDemo: true`,不得进入交付判断。

规则:

1. 检测到缺少 `comtypes` / `win32com` / `pythoncom` 时,默认执行 `python -m pip install "pywin32>=305" "comtypes>=1.2.0"` 补齐依赖;安装失败时说明原因和手动方法。 2. 环境变量 `SW_AUTO_INSTALL_DEPENDENCIES=off` 或 `sw_preflight.py --no-install` 可关闭自动安装。 3. 检测不到 SolidWorks 安装或 COM 注册时,停止原生 SolidWorks 操作;若原生格式并非必需且 `fallbackPolicy=allow_open_formats`,继续执行无头开放格式后端,不要把整个任务误标为失败。

Python 依赖提醒

按任务最小化安装依赖,不要在普通零件建模时强制安装网格转换库;工程图交付需要标准 `requirements.txt` 中的 PyMuPDF:

# 核心 SolidWorks COM 自动化依赖
python -m pip install -r SKILL_DIR\requirements.txt

# 仅在需要 GLB/GLTF/OBJ/STL 网格检查、缩放或转换时安装
python -m pip install -r SKILL_DIR\requirements-mesh.txt

执行涉及 GLB/GLTF/FBX/BLEND 转 OBJ/STL 的任务前,先用 `importlib.util.find_spec()` 检查 `trimesh`、`pygltflib`、`PIL` 是否可用;缺失时先提示用户需要安装哪些库和用途,再安装或给出手动命令。

连接 SolidWorks

import sys; sys.path.insert(0, r"SKILL_DIR/scripts")
from sw_connect import mm
from sw_part import sketch, sketch_circle, extrude_boss
from sw_sketch_quality import fully_define_sketch
from sw_session import SolidWorksSession

with SolidWorksSession(version=2026) as session:
    model = session.new_part()

    with sketch(model, "Front Plane") as sketch_name:
        sketch_circle(model, 0, 0, mm(25))
        fully_define_sketch(model)

    if extrude_boss(model, sketch_name, mm(50)) is None:
        raise RuntimeError("拉伸失败")
    if not session.save(model, r"C:\temp\cylinder.sldprt"):
        raise RuntimeError("保存失败")
    if not session.export(model, r"C:\temp\cylinder.step"):
        raise RuntimeError("导出失败")

> 将 `SKILL_DIR` 替换为此技能的实际安装路径。

模型交付要回读草图的约束状态、尺寸与关系,禁止批量 Fix 代替设计参数;保存重开后验证草图被目标特征消费、关键尺寸可改且孔位保持正确。基础圆/矩形可用 `fully_define_sketch()`;复杂草图应明确设计尺寸和关系,再用 `inspect_model_sketches()` 验收,缺证据时保留人工复核。

会话上下文只清理本轮登记的文档和确认归属的空实例;达到文档预算时先处理本轮文件。执行标记失败、重建失败、未知检查结果或人工复核尚未完成时,不得宣称任务完成。远程 MCP 通过 `artifact_refs` 取回 PNG 或原始文件并核对 SHA-256,规则见 `mcp-server/README.md`。

核心工作流

根据用户需求选择对应模块:

| 需求 | 脚本 | 参考文档 | |---|---|---| | 入口自检与依赖补齐 | `scripts/sw_preflight.py` | `references/troubleshooting.md` | | 无 CAD 开放格式写入 | `scripts/headless_cad_writer.py`、`scripts/cad_studio.py write-open-format` | `capabilities.yaml`、公共 CAD Core Schema | | 高级能力/类型库探测 | `scripts/sw_capability_probe.py` | `references/complex-mechanical-routing.md` | | Python/C#/C++/SWBasic/OCCT 后端选择 | `scripts/backend_router.py` | `references/language-backend-routing.md`、`capabilities.yaml` | | C# 进程内 Add-in 宿主、事件与 UI | `scripts/sw_addin_host.ps1`、`scripts/sw_addin_host.py` | `references/solidworks-addin-host.md` | | 多模型宏生成防护 | `scripts/sw_macro_guard.py` | `references/openclaw.md` | | 友好会话 API | `scripts/sw_session.py` | - | | 连接与文档

Read more
@wzyn20051216
Ships withsolidworks-automation-skill

AI Skill + MCP toolkit for reliable desktop CAD automation. 让 Codex、Claude、Cursor 等 Agent 通过自然语言调用真实 CAD 软件,并对执行结果进行验证与追踪。 Tool success is not treated as task success.

Stars on GitHub

Momentum

stars in total
1.6k
Star history of wzyn20051216/solidworks-automation-skill on GitHub, a chart by star-history.com

More skills from other plugins.

agent-builder

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, and…

n8n11d209k
@n8n-io@n8n-ioInstall Skill
browser-use

browser-use

Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…

@browser-use@browser-useInstall Skill
agent-browser

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…

@vercel-labs-2@vercel-labs-2Install Skill
add-anydoc

add-anydoc

Add local office-document-to-Markdown conversion to NanoClaw agent containers with the pinned Firecrawl AnyDoc CLI. Use when…

@nanocoai@nanocoaiInstall Skill

Questions about solidworks-automation-skill.

Which coding agents can use solidworks-automation-skill?
solidworks-automation-skill installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.