alivirgo/Major-AI-Skills / plugins/mas-cad-studio/skills/solidworks
solidworks
VerifiedAutomate SOLIDWORKS parts and assemblies with COM, Python, and VBA; inspect FeatureManager rebuild errors, configure mates, and batch-export CAD files.
Dassault Systèmes SOLIDWORKS AI Skill Guide (Claude)
Overview & Engine Architecture
SOLIDWORKS (pin year e.g. 2024 SP5) exposes COM automation (SldWorks.Application), VBA macros (.swp), .NET interop, and Document Manager (headless metadata without full UI). Claude acts as CAD Automation Engineer: batch STEP/PDF/DXF export, mass properties, configuration sweeps, rebuild diagnostics.
Platform: Windows-only COM; agents must run on machine with licensed SOLIDWORKS. No true Linux headless GUI-less parity for all APIs.
┌─────────────────────────────────────────────────────────────┐
│ win32com → SldWorks.Application → ModelDoc2 / Extension │
│ Batch: Task Scheduler, /m macro, or standalone .NET │
│ Export: SaveAs3 / ExportToFile2 — check errors VARIANT │
└─────────────────────────────────────────────────────────────┘
When to use / when not to
Use when: parametric BOM/mass reports, configuration export matrices, drawing PDF batches, PDM-adjacent custom steps (respect PDM checkout rules).
Do not use when: cloud-native CAD without SW license; expecting macOS COM; replacing PDM workflow without vault API review.
Operational Capabilities & Agent Directives
- COM lifecycle:
Dispatch("SldWorks.Application"); setVisibleintentionally;Quitonly when script owns instance. - Rebuild truth: After sketch/equation edits use Ctrl+Q full rebuild, not Ctrl+B.
- Export integrity: Always read
errors/warningsfromSaveAs3/ExportToFile2VARIANT byref ints. - Deterministic exports: Fixed configuration name (
"Default"vs"@config"); suppress design table driven configs explicitly in script. - Large assemblies: Lightweight / SpeedPak before mass ops; avoid resolving all components for metadata-only jobs — prefer Document Manager when licensed.
- Units: API returns meters for mass properties — document conversion to mm/kg for reports.
Production Python: STEP AP214 batch from active doc
import win32com.client
from win32com.client import VARIANT
import pythoncom
def export_step(path: str) -> None:
pythoncom.CoInitialize()
sw = win32com.client.Dispatch("SldWorks.Application")
sw.Visible = False
model = sw.ActiveDoc
if model is None:
raise RuntimeError("No active document")
ext = model.Extension
errors = VARIANT(pythoncom.VT_BYREF | pythoncom.VT_I4, 0)
warnings = VARIANT(pythoncom.VT_BYREF | pythoncom.VT_I4, 0)
ok = ext.SaveAs3(path, 0, 2, None, None, errors, warnings)
if not ok or errors.value != 0:
raise RuntimeError(f"SaveAs failed err={errors.value} warn={warnings.value}")
Launch with existing session or OpenDoc6 with full path; PDM: checkout first or export fails.
Failure taxonomy
| Symptom | Cause | Fix |
|---|---|---|
| Red/yellow Feature tree | Dangling relations | What's Wrong? / Dangling filter |
| Over-defined mates | Red mate folder | Mate Diagnostics |
| Export empty STEP | Lightweight unresolved | Resolve or export from part |
| COM E_FAIL | SW not running / wrong ProgID | Start SW; match bitness (64-bit) |
| Drawing PDF missing sheets | Wrong sheet selection | ExportPdfData sheet array |
CLI: "sldworks.exe" /m "C:\Macros\batch.swp" for scheduled batch.
Agent Operational Directive
MANDATORY: Check SaveAs error VARIANTs. Pin SOLIDWORKS year. Use full rebuild after param changes. Respect PDM checkout; never bypass vault locks in automation without explicit user authorization.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |