Skip to the content.

SwPy architecture

 ┌──────────────────────────────────────────────────────────────────────┐
 │ L5  External bridge   JSON-RPC (named pipe / localhost)              │
 │     clients: Jupyter, Excel, Grasshopper, MCP, tests                 │
 ├──────────────────────────────────────────────────────────────────────┤
 │ L4  Tools & UI        task pane editor + REPL, script toolbar,       │
 │                       event hooks (on_rebuild, on_save ...)          │
 ├──────────────────────────────────────────────────────────────────────┤
 │ L3  Pythonic API      `swpy` pure-Python package: units, dims,       │
 │                       features, geometric selection, batch(), pandas │
 ├──────────────────────────────────────────────────────────────────────┤
 │ L2  Raw API surface   typed interop objects injected as `sw`, `doc`; │
 │                       swconst enums; out-params as tuples            │
 ├──────────────────────────────────────────────────────────────────────┤
 │ L1  Python runtime    pythonnet engine: locate/init CPython once,    │
 │                       GIL, stdout/stderr capture, sessions, `# r:`   │
 ├──────────────────────────────────────────────────────────────────────┤
 │ L0  Host add-in       C# net48 COM ISwAddin: lifecycle, per-user     │
 │                       registration, main-thread dispatcher, logging  │
 └──────────────────────────────────────────────────────────────────────┘
                       SOLIDWORKS process (single STA UI thread)

Each layer only depends on layers below it. L3 is plain Python and can also run out-of-process over pywin32/L5 for users without the add-in.

L0 - Host add-in (src/SwPy.AddIn, C#, net48, x64)

L1 - Python runtime (SwPy.AddIn/Python/*)

L2 - Raw API surface

L3 - Pythonic API (python/swpy, pure Python)

L4 - Tools & UI

L5 - External bridge

Milestones (test as we go)

| # | Deliverable | Test | |—|—|—| | 0a | Spike A: minimal add-in loads in SW 2020 without admin | external pywin32 GetAddInObject returns object | | 0b | Spike B: pythonnet inside SW runs code against sw | Execute("result = sw.RevisionNumber()") | | 1 | L0+L1+L2 solid: sessions, output capture, errors, logging | pytest suite via pywin32 harness | | 2 | L3 swpy core: units, dims/globals, mass, batch | pytest against a generated test part | | 3 | L4 task pane editor + REPL | manual + screenshot | | 4 | L5 bridge (done over COM) + swpy.client.connect() | pytest via client | | 5 | Packaging: embeddable Python, # r: installs, installer | clean-user install test | | 6 | Editor IDE features + user guide/API reference | pane + editor-service tests, guide examples executed (test_docs.py) |