SolidWorks MCP Python
# SolidWorks MCP Python — 中文本地化补丁版
[](https://www.python.org/downloads/)
[](https://www.solidworks.com/)
[](LICENSE)
本仓库是 [andrewbartels1/SolidworksMCP-python](https://github.com/andrewbartels1/SolidworksMCP-python) 的补丁版本,增加了对简体中文 SolidWorks 的视图名称兼容,并加强了一键工程图的布局校验。
> 这是非官方补丁仓库,与 Dassault Systèmes 及上游仓库维护者没有隶属关系。
完整的上游功能说明请参阅上游项目 README。
## 补丁内容
- SolidWorks 英文视图名失败时,自动尝试简体中文名称:
- `*Front` → `*前视`
- `*Back` → `*后视`
- `*Left` → `*左视`
- `*Right` → `*右视`
- `*Top` → `*上视`
- `*Bottom` → `*下视`
- `*Isometric` → `*等轴测`
- `*Trimetric` → `*三轴测`
- `*Dimetric` → `*二轴测`
- `*Current` → `*当前视图`
- 单个工程图视图与 `generate_drawing_package` 共用本地化名称回退。
- 中文视图方向可以正确识别为前视图、俯视图和侧视图。
- 自动布局会读取实际视图边界;视图移动失败或超出图纸时自动降低比例。
- 保存和导出 PDF 前强制重建图纸,并再次验证所有视图仍在规划区域内。
- 无法得到合格版面时返回明确错误,不再静默生成“看似成功”的图纸。
## 已验证环境
- Windows 11
- SolidWorks 2026 SP0.0,简体中文
- Python 3.13.4
- `solidworks-mcp-python` 2.1.0 + 本仓库补丁
验证结果:
- 上游相关适配器测试:496 项通过
- 工程图与本地化专项测试:102 项通过
- 实机自检:零件、装配体、工程图和 STEP 导出 4/4 通过
## 安装
需要 Windows、Python 3.13+、`uv`,以及至少启动过一次的 SolidWorks。
```powershell
git clone https://github.com/locense/solidworks-mcp-python-patched.git
cd solidworks-mcp-python-patched
uv venv .venv --python 3.13
uv pip install --python .venv\Scripts\python.exe -e .
```
运行实机自检:
```powershell
.\.venv\Scripts\solidworks-mcp-python.exe selftest --year 2026
```
运行测试依赖:
```powershell
uv pip install --python .venv\Scripts\python.exe -e ".[test]"
```
## Codex MCP 配置
将路径替换为本仓库的实际位置:
```toml
[mcp_servers.solidworks]
command = 'C:\path\to\solidworks-mcp-python-patched\.venv\Scripts\solidworks-mcp-python.exe'
args = ["--year", "2026"]
cwd = 'C:\path\to\solidworks-mcp-python-patched'
startup_timeout_sec = 240.0
tool_timeout_sec = 1800.0
[mcp_servers.solidworks.env]
SOLIDWORKS_MCP_TOOL_MODE = "search"
PYTHONIOENCODING = "utf-8"
PYTHONUNBUFFERED = "1"
PYTHONUTF8 = "1"
```
`SOLIDWORKS_MCP_TOOL_MODE="search"` 只向模型暴露四个入口工具,避免一次加载全部 150 多个工具。删除该环境变量可恢复完整工具列表。
配置变更后需要完全退出并重新打开 Codex。
## 已知限制
- 一键工程图遇到极小的尺寸标注时,仍可能报告 `line_through_own_view` 等标注冲突。
- 此类冲突现在会明确返回错误,不会将存在排版问题的图纸标记为成功。
- 建议生成图纸后打开 PDF 做一次视觉检查,尤其是尺寸密集的小型零件。
## 来源与许可
本项目基于上游 MIT 许可代码修改。原始版权声明保留在 [LICENSE](LICENSE) 中。
本仓库同样以 [MIT License](LICENSE) 发布。
- 上游项目:<https://github.com/andrewbartels1/SolidworksMCP-python>
- 上游完整 README:<https://github.com/andrewbartels1/SolidworksMCP-python#readme>
TDQS
Scored across 157 tools
Each tool's description explicitly states its purpose and cross-references alternatives, which keeps most selections clear, but the surface carries several genuine near-duplicates: load_part/load_assembly vs open_model, save_part/save_assembly vs save_file, get_file_properties vs get_model_info, calculate_mass_properties vs get_mass_properties, and add_drawing_view vs create_drawing_view. Deprecated aliases mitigate the risk by naming their replacement, but an agent can still land on the superseded tool. The nine generate_vba_* tools plus create_* equivalents form another cluster that only the prose keeps apart.
Names are uniformly snake_case with a verb-led convention across most of the surface (create_, add_, list_, get_, set_, export_, generate_, check_, verify_). A minority are noun-led or bare-noun patterns (sketch_mirror, sketch_trim, pattern_linear, mirror_feature, measure_entities), and add_fillet/add_chamfer vs add_sketch_fillet/add_sketch_chamfer show the sketch/solid split is expressed inconsistently. Still highly readable with only minor deviations.
157 tools is far beyond a manageable surface; even for a full CAD application this is a large, layered API exposed at once. Deprecated aliases (load_part, save_part, calculate_mass_properties, get_file_properties, add_drawing_view, sketch_tutorial_simple_hole) and the redundant generate_vba_* family inflate the count without adding capability. The breadth of sub-domains justifies many tools, but not this many, and grouping/packs would help.
Coverage is unusually deep: sketching primitives and constraints, boss/cut extrude, revolve, sweep, loft, fillet/chamfer/draft/rib/shell, hole wizard, sheet metal with flat pattern and DXF export, assembly mates/components/patterns/interference, drawings with views, dimensions, GD&T, BOM, and a wide export set. Remaining gaps are modest (no cut-sweep/cut-loft, no body delete or combine/split beyond save_body_as_part, no delete_custom_property, no component delete), which agents can route around or handle via macros.