SOLIDWORKS 2025 IO Loop
Use this skill for live SOLIDWORKS 2025 work. The active document is the source
of truth: perform the requested model change, then read SOLIDWORKS back to prove
the result.
Project Boundary
When working under D:\skills\codex\SW2025, this project is isolated. Use this
skill, its bundled scripts, and this project's docs/ knowledge base as the
authority. Do not silently import assumptions, scripts, shortcut mappings, macro
conclusions, or validation results from other projects. Use outside material
only when explicitly requested, and verify the result against live SOLIDWORKS
2025 or this local project before making it reusable here.
First Move
- Attach to the running app with
SldWorks.Application; do not launch
SOLIDWORKS unless the user asks.
- Prefer the unified runner:
python ".\skills\solidworks-2025-io-loop\scripts\solidworks_sw2025.py" <command> [options]
- For geometry edits, verify by counting bodies, faces, sketch segments,
created circles, or matching model edges after the feature is built.
- If a script reports partial creation, do not cut or continue silently; clean
the partial sketch and retry with the proven workflow.
Command Map
| Task |
Command |
| IO write/read check |
io |
| Active part metrics |
metrics |
| Create cube |
cube --size-mm 100 |
| Selected face area |
face-metrics |
| Selected face airflow |
airflow --velocity 12 |
| Extract active-body edges to 3D sketch |
extract-body-edges |
| Extract selected edges/faces/body to 3D sketch |
extract-selection |
| Selected face outward centerline |
face-centerline --length-mm 50 |
| Connect visible solid-body centers |
connect-centers |
| Circular flange holes |
circle-flange --count 8 --hole-diameter-mm 15 --edge-distance-mm 35 |
| Rectangular flange holes |
rect-flange --hole-diameter-mm 8 --edge-distance-mm 20 --x-count 8 --y-count 6 |
| Export shortcut inventory |
shortcuts export --out ".\docs\solidworks_shortcuts_inventory.json" |
| Rebuild macro knowledge |
macro-knowledge |
| Resolve or run registered macro |
run-macro --macro "法兰孔生成" --dry-run |
Proven Workflows
cube: a 100 mm cube should read back as one body, six faces,
1,000,000 mm^3 volume, and 60,000 mm^2 area.
extract-selection: accepts selected edges, faces, or solid bodies and makes
a 3D sketch from the selected geometry.
face-centerline: default direction is the selected face normal, not global Z.
connect-centers: sorts visible solid bodies along X and creates a 3D sketch
through their mass centers.
circle-flange: uses the user's proven AddToDB bulk sketch pattern, then
verifies hole_count * 2 circular through-hole edges after cutting.
rect-flange: places holes along the rectangular perimeter. X/Y counts include
corners, so x=8, y=6 creates 8*2 + (6-2)*2 = 24 holes.
Macro Knowledge
Project-level references live under docs/:
docs/SOLIDWORKS_2025_HELP_KNOWLEDGE.md
docs/SOLIDWORKS_2025_HELP_INDEX.json
docs/SOLIDWORKS_SHORTCUTS.md
docs/solidworks_shortcuts_inventory.json
docs/SOLIDWORKS_MACRO_KNOWLEDGE.md
docs/SOLIDWORKS_MACRO_KNOWLEDGE.json
docs/FLANGE_HOLE_CREATION_RULES.md
docs/extracted_registered_macros/
docs/macro_txt/
Before menu-heavy UI work, check the shortcut/macro references first. Useful
registered macros include 法兰孔生成, 阵列优化, 公垂线, 点面垂直线段,
多实体重心草图提取, 实体内外轮廓全提取, 实体中心线提取, 合并草图升级,
and 2D3D草图缩放.
Treat .swp files as binary VBA containers. Extract source, back up the original
macro, and avoid direct binary edits unless the writer is proven safe.
SOLIDWORKS 2025 COM Rules
- Many pywin32 COM members are exposed as properties. Use a helper that accepts
both method and property forms before calling fragile APIs.
- Use
win32com.client.VARIANT(pythoncom.VT_DISPATCH, None) when SOLIDWORKS
selection APIs need a null dispatch.
model.Extension.CreateMassProperty may be property-like in this environment.
- For flange-hole sketches, ordinary
CreateCircle / CreateCircleByRadius
can silently miss lower-half positions. Use SetAddToDB(True) plus
SetDisplayWhenAdded(False), restore both settings in finally, and read
back the model edge count after cutting.
- Keep user-visible output Chinese when reporting model operations, but keep
scripts ASCII-safe where possible.
1---2name: solidworks-2025-io-loop3description: SOLIDWORKS 2025 IO Loop4---56# SOLIDWORKS 2025 IO Loop78Use this skill for live SOLIDWORKS 2025 work. The active document is the source9of truth: perform the requested model change, then read SOLIDWORKS back to prove10the result.1112## Project Boundary1314When working under `D:\skills\codex\SW2025`, this project is isolated. Use this15skill, its bundled scripts, and this project's `docs/` knowledge base as the16authority. Do not silently import assumptions, scripts, shortcut mappings, macro17conclusions, or validation results from other projects. Use outside material18only when explicitly requested, and verify the result against live SOLIDWORKS192025 or this local project before making it reusable here.2021## First Move22231. Attach to the running app with `SldWorks.Application`; do not launch24 SOLIDWORKS unless the user asks.252. Prefer the unified runner:2627```powershell28python ".\skills\solidworks-2025-io-loop\scripts\solidworks_sw2025.py" <command> [options]29```30313. For geometry edits, verify by counting bodies, faces, sketch segments,32 created circles, or matching model edges after the feature is built.334. If a script reports partial creation, do not cut or continue silently; clean34 the partial sketch and retry with the proven workflow.3536## Command Map3738| Task | Command |39| --- | --- |40| IO write/read check | `io` |41| Active part metrics | `metrics` |42| Create cube | `cube --size-mm 100` |43| Selected face area | `face-metrics` |44| Selected face airflow | `airflow --velocity 12` |45| Extract active-body edges to 3D sketch | `extract-body-edges` |46| Extract selected edges/faces/body to 3D sketch | `extract-selection` |47| Selected face outward centerline | `face-centerline --length-mm 50` |48| Connect visible solid-body centers | `connect-centers` |49| Circular flange holes | `circle-flange --count 8 --hole-diameter-mm 15 --edge-distance-mm 35` |50| Rectangular flange holes | `rect-flange --hole-diameter-mm 8 --edge-distance-mm 20 --x-count 8 --y-count 6` |51| Export shortcut inventory | `shortcuts export --out ".\docs\solidworks_shortcuts_inventory.json"` |52| Rebuild macro knowledge | `macro-knowledge` |53| Resolve or run registered macro | `run-macro --macro "法兰孔生成" --dry-run` |5455## Proven Workflows5657- `cube`: a 100 mm cube should read back as one body, six faces,58 `1,000,000 mm^3` volume, and `60,000 mm^2` area.59- `extract-selection`: accepts selected edges, faces, or solid bodies and makes60 a 3D sketch from the selected geometry.61- `face-centerline`: default direction is the selected face normal, not global Z.62- `connect-centers`: sorts visible solid bodies along X and creates a 3D sketch63 through their mass centers.64- `circle-flange`: uses the user's proven AddToDB bulk sketch pattern, then65 verifies `hole_count * 2` circular through-hole edges after cutting.66- `rect-flange`: places holes along the rectangular perimeter. X/Y counts include67 corners, so `x=8`, `y=6` creates `8*2 + (6-2)*2 = 24` holes.6869## Macro Knowledge7071Project-level references live under `docs/`:7273- `docs/SOLIDWORKS_2025_HELP_KNOWLEDGE.md`74- `docs/SOLIDWORKS_2025_HELP_INDEX.json`75- `docs/SOLIDWORKS_SHORTCUTS.md`76- `docs/solidworks_shortcuts_inventory.json`77- `docs/SOLIDWORKS_MACRO_KNOWLEDGE.md`78- `docs/SOLIDWORKS_MACRO_KNOWLEDGE.json`79- `docs/FLANGE_HOLE_CREATION_RULES.md`80- `docs/extracted_registered_macros/`81- `docs/macro_txt/`8283Before menu-heavy UI work, check the shortcut/macro references first. Useful84registered macros include `法兰孔生成`, `阵列优化`, `公垂线`, `点面垂直线段`,85`多实体重心草图提取`, `实体内外轮廓全提取`, `实体中心线提取`, `合并草图升级`,86and `2D3D草图缩放`.8788Treat `.swp` files as binary VBA containers. Extract source, back up the original89macro, and avoid direct binary edits unless the writer is proven safe.9091## SOLIDWORKS 2025 COM Rules9293- Many pywin32 COM members are exposed as properties. Use a helper that accepts94 both method and property forms before calling fragile APIs.95- Use `win32com.client.VARIANT(pythoncom.VT_DISPATCH, None)` when SOLIDWORKS96 selection APIs need a null dispatch.97- `model.Extension.CreateMassProperty` may be property-like in this environment.98- For flange-hole sketches, ordinary `CreateCircle` / `CreateCircleByRadius`99 can silently miss lower-half positions. Use `SetAddToDB(True)` plus100 `SetDisplayWhenAdded(False)`, restore both settings in `finally`, and read101 back the model edge count after cutting.102- Keep user-visible output Chinese when reporting model operations, but keep103 scripts ASCII-safe where possible.