Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 2.12 KB

File metadata and controls

29 lines (25 loc) · 2.12 KB

SwPy user guide

SwPy runs real CPython inside SOLIDWORKS: a script editor in the task pane, a Pythonic layer over the API (model.dims["D1@Boss-Extrude1"] = 30*mm), the full SOLIDWORKS API with automatic typing, pip packages, and remote control from Jupyter or any Python.

Guide What you learn
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, translating VBA/C# samples
6. Packages # r: numpy - using pip packages in scripts
7. Remote control Drive SOLIDWORKS from Jupyter, scripts, Excel or C#
8. Recipes Copy-paste solutions: parts, studies, exports, properties, assemblies
9. Troubleshooting Logs, common errors and their fixes
10. Events Run Python when SOLIDWORKS rebuilds, saves, selects, switches documents
11. Script buttons and user interaction Script folder, toolbar buttons, startup scripts, progress bars, dialogs
12. Building models Sketches, extrude/cut/revolve/fillet/chamfer/shell, assemblies and mates, drawings, export
API reference Every public class, function and constant of swpy

Conventions used throughout:

  • SI units everywhere - metres, radians, kilograms - exactly like the SOLIDWORKS API. Write 30 * mm, read with to(value, mm).
  • Python code blocks are complete scripts: paste them into the editor and press F5. Unless a guide says otherwise they expect an open part. The examples are executed against SOLIDWORKS by the test suite (tests/test_docs.py), so they stay correct.