Skip to the content.

9. Troubleshooting

Where to look first

The SwPy pane does not appear

Cause Fix
SOLIDWORKS was started normally, not via the SOLIDWORKS + SwPy shortcut Use the shortcut, or install with install.ps1 -Machine (admin) so SOLIDWORKS loads SwPy itself
The add-in is not registered (moved folder, other Windows user) Run tools\install.ps1 again from the SwPy folder
SOLIDWORKS runs as administrator Per-user registration is invisible to elevated processes: start SOLIDWORKS normally
A message box “SwPy could not be loaded” Read the message and swpy.log; usually a missing or blocked file in the SwPy folder

“Python failed to start”

SwPy looks for Python in this order: the SWPY_PYTHON_HOME environment variable, the bundled python-runtime folder next to the add-in, then installed Python versions (3.12 preferred). Check swpy.log for the path it tried. A failed start is remembered until SOLIDWORKS restarts.

A script “does nothing”

Many API methods fail silently: they return None, False or an error code instead of raising.

Common errors

Error Meaning / fix
AttributeError: IModelDocExtension has no attribute 'CustomPropertyManager'. Did you mean: 'get_CustomPropertyManager'? An indexed property: call get_CustomPropertyManager("") (details)
AttributeError: 'NoneType' object has no attribute ... An API call returned None (no active document, nothing selected, wrong name). Check the value before using it
KeyError: 'D1@Sketch1' from model.dims[...] No dimension with that name - print model.dims.names()
TypeError: No method matches given arguments Wrong number or type of arguments. Check the signature help (type (), and pass None for unused object parameters
NameError: name 'doc' ... / doc is None No document is open (or the active window is not a document)
RuntimeError: pip install failed See the pip output in the message: no internet, a typo in the package name, or no wheel for Python 3.12 x64

Other API libraries

Types and units

Never import the interop assemblies

from SolidWorks.Interop.sldworks import ... may bind to a trimmed copy embedded by another add-in and fail in confusing ways. Use sldworks.IFoo(obj) for casts and swconst for enums.

Long scripts freeze SOLIDWORKS

Scripts run on the SOLIDWORKS UI thread, so SOLIDWORKS waits until they finish. Use model.batch() around many edits and wrap long loops in ui.progress(...) - then Esc stops them. A loop without ui.progress cannot be interrupted other than by closing SOLIDWORKS - save your work before experimenting.

The SwPy toolbar / CommandManager tab does not appear

SOLIDWORKS only shows toolbars, menus and CommandManager tabs of add-ins registered machine-wide. Install with tools\install.ps1 -Machine (needs admin once), or use Scripts ▾ in the SwPy pane, which always works.

Reporting a problem

Include the SOLIDWORKS version (sw.RevisionNumber()), the script, the full output and the end of swpy.log.