Communitygithub.com

LTGOz/solidworks-agent-skill

AI Agent 技能包:JSON 配方驱动 SolidWorks 2023 参数化建模(草图/拉伸/旋转/切除/圆角/倒角/装配/GV多规格)+ trimesh 几何断言 + STL 切片验证,附实测 COM 踩坑手册。Agent Skill for ZCode/Claude Code.

solidworks-agent-skill 是什么?

solidworks-agent-skill is a Claude Code agent skill that aI Agent 技能包:JSON 配方驱动 SolidWorks 2023 参数化建模(草图/拉伸/旋转/切除/圆角/倒角/装配/GV多规格)+ trimesh 几何断言 + STL 切片验证,附实测 COM 踩坑手册。Agent Skill for ZCode/Claude Code.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add LTGOz/solidworks-agent-skill

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

SolidWorks 2023 Native Automated Modeling (Recipe-Driven · Proven in Practice)

Package "describe object → JSON modeling recipe → SolidWorks direct draw" into a single command, with programmatic geometry verification.

Repository Layout

PathDescription
sw_bridge.pyCore bridge: recipe-driven, one command for modeling→save→export→assertion
stl_slicer.pySTL ASCII slice verification (programmatic confirmation of contours/holes/slots, no image reading)
recipes/Ready-made recipe examples (including full-chain self-test recipe_best_practices_test.json)
dfm_check.py + rules/Product structure DFM checker: injection molding (16 rules)/3D printing (14 rules) dual-process quantitative rule base, design parameter table check + recipe lint
skills/sw-dfm-injection/Branch skill: injection molding DFM (DVT/volume production, wall thickness/draft/snap/Boss/rib/undercut quantitative rules)
skills/sw-dfm-proto/Branch skill: 3D printing prototype DFM (EVT, minimum feature/overhang/gap/drain hole quantitative rules)
references/api-pitfalls.mdComplete hard-learned lessons: COM/signature/VARIANT/EquationMgr/ROT pitfalls, must-read before writing new capabilities
references/recipe-cookbook.mdRecipe syntax details + templates + multi-spec/assertion usage
references/industry-best-practices.mdIndustry paradigm research summary + subsequent refactoring checklist
docs/case_mcp1085_box.mdReal delivery case: two-layer water pipe inspection box
config.example.jsonMachine-specific configuration template (template path/ProgID/output directory)

Environment Prerequisites (All Required)

  1. Windows + Genuine SolidWorks 2023 running. COM can only attach to an interactive session (GetObject), cannot run headless, nor be launched by script (COM-launched instances cannot register ROT, see api-pitfalls §13).
  2. Python 3.10+, pip install -r requirements.txt (pywin32 / trimesh / manifold3d / numpy / pillow).
  3. Chinese national standard template paths have built-in defaults; for English version or custom templates, copy config.example.json to config.json and modify.

Quick Self-Check

python sw_bridge.py --demo block        # Build block + export + geometry assertion all-in-one
python sw_bridge.py --demo vase         # Spline revolve surface
python stl_slicer.py --stl demo_output/demo_block.STL --level 5   # Slice to view cross-section

Standard Workflow

  1. Write recipe JSON (syntax and templates in references/recipe-cookbook.md)
  2. Execute: python sw_bridge.py --recipe-file recipes/xxx.json
  3. Verify: Recipe built-in verify assertions (watertightness/volume/bounding box/golden IoU), failure means entire recipe fails; then use stl_slicer.py to view cross-sections
  4. Export views: Multiple view ops export multi-angle PNGs; fmt: step for downstream
  5. Structure review (product parts): python dfm_check.py --design parameter_table.json --process both — injection molding/3D printing dual-process DFM check, FAIL means gate not passed; see branch skills in skills/

Recipe op Overview (Full parameters in cookbook)

opDescription
new_part / new_assembly / openDocument operations
sketch / sketch_end / centerline / spline / line / rect / circle / arcSketch (mm)
extrude / revolve / cut / fillet / chamferFeatures (auto retry degrade on failure)
set_global_variable / add_equationGlobal variables/equations → multi-spec variants via GV mutation
view / save / export / add_component / import_meshView/Save/Export stl·png·step·iges/Assembly/Mesh import
verifytrimesh assertion layer (watertight/volume/bounding box/golden IoU)

During execution, graphics refresh/feature tree are automatically frozen (performance wrapper), and finalized with unified ForceRebuild3+ForceRebuildAll.

Hard Rules Quick Reference (Full version in references/api-pitfalls.md)

  1. API length unit is always meters, write mm in recipes (bridge auto-converts).
  2. FeatureRevolve2 has 20 parameters; the 4/5/7 parameter versions generated by the type library are all wrong.
  3. In late binding, Callout/ExportData must pass VARIANT(VT_DISPATCH, None); CreateSpline2 point array must be VT_ARRAY|VT_R8.
  4. Enter/exit sketch use InsertSketch(True) (Toggle).
  5. Chinese localized names: 前视基准面/草图1/*等轴测 (config can switch to English environment candidate).
  6. Complex features (>12 params) fail → ultimate fallback: SW record macro → RunMacro2 playback.
  7. GetEquationMgr is propget-only, must force PROPERTYGET by dispid (see api-pitfalls §12).
  8. For complex API signatures, first check SW's installed type library (makepy) or record macro, don't guess from memory.

Version Compatibility Notes

This package is tested and proven on SW2023 Chinese national standard version (including dispid 66286, ProgID .31, 20-param FeatureRevolve2, and other version-specific details). Other SW versions share the core workflow, but version-specific constants need to be re-verified using api-pitfalls §12's method (makepy type library/record macro).

Tested / Untested Boundaries

  • ✅ Extrude, revolve, spline, rectangle/circle/arc, cut, fillet, chamfer, assembly add component, GV/equations, STL/STEP/IGS/PNG export, mesh import, geometry assertions
  • ❌ Sweep/loft/pattern/mate not tested (theoretically same approach, check signatures via type library or macro record first)

相关技能