name: solidworks-2025-io-loop
description: Use when SOLIDWORKS 2025 is already open on Windows and Codex must operate the active part through COM with read-back proof: create/measure geometry, extract sketches, connect centers, create circular or rectangular flange holes, read macro shortcuts, or reuse the user's registered SolidWorks macros.
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.