Skip to the content.

SwPy - Python for SOLIDWORKS

SwPy embeds real CPython inside SOLIDWORKS: a script editor in the task pane with IntelliSense from your live model, a Pythonic API for parts, assemblies and drawings, every SOLIDWORKS API library, pip packages, events, script buttons, and remote control from Jupyter.

SwPy editor in the SOLIDWORKS task pane

with model.sketch(model.planes.front) as s:
    s.rect((0, 0), 100 * mm, 60 * mm)
model.extrude(s, 20 * mm)
model.fillet(model.edges.parallel(Z), 5 * mm)
model.export("bracket.step")

Download the latest release - Windows 10/11 x64, SOLIDWORKS 2020 or newer, no admin rights and no Python install needed.

User guide

   
1. Getting started Install, open the editor, run your first script
2. The editor Tabs, IntelliSense, signature help, F1 API help, find/replace, shortcuts
3. Scripting basics What is predefined in a script, sessions, output, errors
4. The model API Units, dimensions, global variables, batch edits, mass, face/edge queries
5. The SOLIDWORKS API from Python Auto-typed objects, casts, enums, arrays, out-parameters, other API libraries
6. Packages # r: numpy - pip packages in scripts
7. Remote control Jupyter, scripts, Excel, C#
8. Recipes Copy-paste solutions
9. Troubleshooting Logs and common errors
10. Events Run Python when SOLIDWORKS rebuilds, saves, selects
11. Script buttons and user interaction Script folder, startup scripts, progress bars, dialogs
12. Building models Sketches, features, assemblies, drawings, export
API reference Every public class and function

Source on GitHub · Changelog · Architecture · Security