Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
20efcf9
feat: equations and global variables drive a part's dimensions
andrewbartels1 Nov 18, 2026
c4ed4e1
fix: equations work on real SolidWorks; a combination wrench demo
andrewbartels1 Nov 18, 2026
4f5500c
fix(equations): don't import pythoncom, so the module loads on CI
andrewbartels1 Nov 18, 2026
35e04a5
wip: wrench open end (local, under review)
andrewbartels1 Nov 18, 2026
aaf22c2
feat(sketch): turn an ellipse and dimension its axes; the wrench gets…
andrewbartels1 Nov 18, 2026
bb5fc21
fix(sketch): dimension an ellipse axis with AddDimension2 beside the …
andrewbartels1 Nov 18, 2026
7a28ced
wip: wrench box end raised along its axis; face fillets first (local,…
andrewbartels1 Nov 18, 2026
c776e50
wip: wrench pattern direction by length; 0.16 x Size face fillets (lo…
andrewbartels1 Nov 18, 2026
d25b101
wip: wrench ring lifted 0.13 x Size so the handle shows no ledge; 51C…
andrewbartels1 Nov 18, 2026
077ef6a
feat(sketch): add_sketch_text, text along a line at a height, mirrore…
andrewbartels1 Nov 18, 2026
cc48648
fix(sketch): add_sketch_text centres on a model point by measuring; n…
andrewbartels1 Nov 18, 2026
214d89c
wip: wrench test gets 1200 s, its rebuilds now carry the lettering (l…
andrewbartels1 Nov 18, 2026
6cdc18e
feat(sketch): set_sketch_text re-letters a sketch with it open (Solid…
andrewbartels1 Nov 19, 2026
627b152
wip: wrench evidence shows the lettering as drawn before each re-lett…
andrewbartels1 Nov 19, 2026
532c37a
wip: wrench hides sketches before framing; lettering pattern tries it…
andrewbartels1 Nov 19, 2026
cd49776
wip: wrench letters its handle after the equations (faster rebuilds),…
andrewbartels1 Nov 19, 2026
d4502d0
fix(sketch): centred text is inserted at its target, so it never show…
andrewbartels1 Nov 19, 2026
dd5683b
wip: wrench demo keeps the camera still (auto normal-to-sketch off, r…
andrewbartels1 Nov 19, 2026
635f130
wip: wrench demo captions each step as it starts, so the GIF's text m…
andrewbartels1 Nov 19, 2026
f9f1b1e
docs: the steel, lettered wrench on the demos page, README and CHANGE…
andrewbartels1 Nov 19, 2026
905efe9
Merge remote-tracking branch 'origin/main' into feat/equations
andrewbartels1 Nov 19, 2026
b37678c
Merge remote-tracking branch 'origin/main' into feat/equations
andrewbartels1 Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **Equations and global variables** (queue item 29): `list_equations`,
`set_equation` and `delete_equation`. One value (`"Width" = 60mm`) can
drive several dimensions (`"D1@Sketch1" = "Width" / 2`); `set_equation`
adds or changes one, in every configuration by default, solves and
rebuilds, and gives the new value. An expression SolidWorks can't use
fails as `equation_refused` and changes nothing. Named configurations
are set one at a time; the reply's `values` gives each one's value. Demo:
one variable sizes a steel combination wrench (13, 19 and 8 mm, 27
equations) whose handle is lettered with its own size, on the demos page
and in the README.
- **`add_sketch_text`**: writes text in the open sketch at a height, and
with `center_at` centres it on a point (measured from the text's own
edges, since SolidWorks' alignment doesn't centre it). The text can show
a custom property (`$PRP:"Name"`), so an equation-driven part can carry
its size; cut or extrude it like any sketch.
- **`set_sketch_text`**: rewrites the text in a named sketch and rebuilds,
giving the text before and after. SolidWorks doesn't redraw sketch text
when an equation changes the part; writing it again does. 145 tools.
- **`add_ellipse` takes an `angle`**, the degrees its major axis is turned
from +x, and **an ellipse can be dimensioned**: `add_sketch_dimension`
with `major_axis` or `minor_axis` on an ellipse's `id` sizes that axis,
so an equation can drive it.
- **`add_polygon` takes an `angle`**: the degrees its first corner is
turned from +x (0 by default), e.g. two hexagons 30° apart for a
12-point opening.
- **A polygon can be dimensioned**: a `diameter` dimension
(`add_sketch_dimension`) on a polygon's `id` sizes it by the circle drawn
inside it, across flats for a hexagon, so an equation can drive it.
- **`save_body_as_part` leaves no extra assembly open** (queue item 27,
#101): a new, unsaved assembly SolidWorks opens alongside Save Bodies is
closed, the part is made active again, and the reply's
Expand Down Expand Up @@ -191,6 +219,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- **`create_cut_extrude` with `both_directions` on a Blind cut** cut one way
only, so a slot meant to straddle its sketch plane came out beside it. It
is now a mid-plane cut, `depth` in total, as `create_extrusion` does.
- **`add_fillet` on the current selection** (empty `edge_names`, after
`select_face_edges`) built no fillet: reading the volume first rebuilt
the part, which cleared the selection. It no longer reads the volume in
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[![SolidWorks](https://img.shields.io/badge/tested%20on-SolidWorks%202026-red)](https://www.solidworks.com/)
[![Coverage](https://codecov.io/gh/andrewbartels1/SolidworksMCP-python/branch/main/graph/badge.svg)](https://codecov.io/gh/andrewbartels1/SolidworksMCP-python)

Python MCP server for SolidWorks automation with 140 tools, plus an optional agent/prompt-testing layer for AI-assisted workflows.
Python MCP server for SolidWorks automation with 145 tools, plus an optional agent/prompt-testing layer for AI-assisted workflows.

[![115 MCP tools by support level (the 8 deprecated ones not counted), and how much of the core SolidWorks COM API they reach](docs/assets/progress/progress.svg)](https://andrewbartels1.com/SolidworksMCP-python/progress/)

Expand Down Expand Up @@ -191,6 +191,7 @@ Each GIF is a live test driving SolidWorks 2026 through the MCP tools, with the
</tr>
<tr>
<td width="33%" valign="top"><a href="https://andrewbartels1.com/SolidworksMCP-python/demos/#hole-positions"><img src="docs/assets/demos/part-features/test_holes_at_several_points-motion.gif" alt="A plate of Hole Wizard holes placed from points, a mirror and a ring" width="100%"></a><br><sub>A plate of Hole Wizard holes from points, a mirror and a ring</sub></td>
<td width="33%" valign="top"><a href="https://andrewbartels1.com/SolidworksMCP-python/demos/#wrench"><img src="docs/assets/demos/equations/test_a_combination_wrench_sized_by_one_variable-motion.gif" alt="A steel combination wrench sized by one global variable and lettered with its size: 13 mm, then 19 mm, then 8 mm in its own configuration" width="100%"></a><br><sub>One variable sizes a combination wrench: equations and configurations</sub></td>
</tr>
</table>

Expand Down Expand Up @@ -366,7 +367,7 @@ It works only with the circuit-breaker adapter wrapper (the default for real Sol

### A shorter tool list

All 140 tools cost about 55,000 tokens a turn. `SOLIDWORKS_MCP_TOOL_MODE=search` lists four instead (about 900 tokens); `SOLIDWORKS_MCP_TOOLSETS=core,drawing` lists only those groups. See [Choose which tools a client sees](https://andrewbartels1.com/SolidworksMCP-python/getting-started/installation/#4-choose-which-tools-a-client-sees).
All 145 tools cost about 59,000 tokens a turn. `SOLIDWORKS_MCP_TOOL_MODE=search` lists four instead (about 900 tokens); `SOLIDWORKS_MCP_TOOLSETS=core,drawing` lists only those groups. See [Choose which tools a client sees](https://andrewbartels1.com/SolidworksMCP-python/getting-started/installation/#4-choose-which-tools-a-client-sees).

## Teach your agent the workflow

Expand Down
59 changes: 59 additions & 0 deletions docs/agents/com-api-pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,65 @@ The SW version picks only `OptimizeGeometry`, never `Sd`.

---

## 36. `IEquationMgr`: no call that takes configuration names works from Python

**Symptom:** `Add3` and `SetEquationAndConfigurationOption` return `-1`, `Status`
reads `-1`, and nothing is added or changed, for any equation text.

**What works** (probed live on SW 2026, 2026-11-17/18):

| Call | Result |
|---|---|
| `Add3(-1, text, True, option, names)`, names as a `VT_BSTR` array, a `VT_VARIANT` array, a tuple, `None` or `pythoncom.Empty` | always `-1` |
| `SetEquationAndConfigurationOption(i, text, 3, names)`, any array form | `-1` |
| `ISetEquationAndConfigurationOption(i, text, 3, 1, names)` | `Invalid number of parameters` |
| `Add2(-1, text, True)` (or `Add`) | adds in every configuration, returns the index |
| `SetEquationAndConfigurationOption(i, text, 1, None)` with the configuration active | `0`: set in that configuration only |
| `SetEquationAndConfigurationOption(i, text, 2, None)` | `0` on a 2-equation part, `-1` on a 19-equation one, even for the same text |
| `Equation(i)` property put (through `IDispatch.Invoke`, `DISPATCH_PROPERTYPUT`) | changes it in every configuration; a bad text leaves it and sets `Status` to `-1` |
| `EvaluateAll()` | returned `-1` on a part that solved: don't trust its return |

**Fix:** add with `Add2`; change in every configuration with the property put; set
named configurations one at a time as "this configuration", each made active, then
show the original again. `Value(i)` is in the document's units (`19.0` for `19mm`).

`adapters/solidworks/equations.py`.

---

## 37. A sketch on a plane at an angle: its x axis may not be the one you expect

**Symptom:** a rectangle meant to run along the part, on a reference plane made
15° from the Front Plane about the y axis, cut a half-depth groove instead.

**Cause:** on that plane SolidWorks 2026 put the sketch's **x along the model's y**
(up) and its y along the part. A rectangle spanning sketch x 0..120 covered the upper
half of the thickness; its sketch y ±60 ran along the whole length.

**Fix:** don't assume an angled plane's sketch axes. Make the profile span both ways
across the direction you don't care about, and check the result (overall size,
volume or body count). The wrench demo's jaw spans sketch x ±60 and picks the sketch-y
side by the measured size.

`tests/live/test_live_sw_equations_wrench.py`, `_jaw`.

---

## 38. Blind `both_directions` on a cut was one-sided; and patterns of patterns build nothing

- **`FeatureCut4` mid-plane needs `T1 = swEndCondMidPlane` (6).** The adapter read
`both_directions` only with Through All, so a Blind cut asked for "both directions"
cut one way: a slot meant to straddle its plane came out beside it. Fixed: Blind with
`both_directions` passes `T1 = 6`, `D1` the total depth.
- **A linear pattern that includes a circular pattern built nothing** (no volume
change; the tool removed the empty feature). Draw the second instance instead: the
wrench's 12-point opening is two hexagon cuts, the second from `add_polygon` with
`angle: 30`.

Found 2026-11-18 building the equations demo.

---

## Adapter wiring traps — not COM, same silent-failure shape

These are not SolidWorks issues, but they fail the same way: the code imports, the tests
Expand Down
2 changes: 1 addition & 1 deletion docs/agents/tool-description-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ name and tell two tools apart by name alone. Pick the verb by meaning:
| `list_` | reads a collection |
| `set_` | changes one value |
| `open_`, `save_`, `close_`, `export_` | file operations |
| `activate_`, `delete_` | makes a document or configuration the active one; removes a feature or configuration |
| `activate_`, `delete_` | makes a document or configuration the active one; removes a feature, configuration or equation |
| `check_`, `verify_`, `measure_`, `compare_` | read-only checks |

`tests/integration/test_tool_descriptions.py` fails on any other name, except
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 44 additions & 6 deletions docs/assets/progress/progress.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"tools": {
"total": 140,
"total": 145,
"by_level": {
"stable": 132,
"stable": 137,
"beta": 0,
"experimental": 0,
"planned": 0,
Expand Down Expand Up @@ -161,7 +161,14 @@
"family": "sketching",
"level": "stable",
"reason": "",
"summary": "Add a driving dimension to sketch entities: linear, angular, radial or diameter."
"summary": "Add a driving dimension to sketch entities: linear, angular, radial, diameter or an ellipse axis."
},
{
"name": "add_sketch_text",
"family": "sketching",
"level": "stable",
"reason": "",
"summary": "Write text in the open sketch, at a point or centred on one, to deboss or emboss it."
},
{
"name": "add_spline",
Expand Down Expand Up @@ -408,6 +415,13 @@
"reason": "",
"summary": "Delete a configuration of the active model; not the active one or the only one."
},
{
"name": "delete_equation",
"family": "equations",
"level": "stable",
"reason": "",
"summary": "Delete an equation or global variable of the active part or assembly, by name."
},
{
"name": "delete_feature",
"family": "modeling",
Expand Down Expand Up @@ -681,6 +695,13 @@
"reason": "",
"summary": "List the views on the active drawing, by name."
},
{
"name": "list_equations",
"family": "equations",
"level": "stable",
"reason": "",
"summary": "List the active part's or assembly's equations and global variables, with their values."
},
{
"name": "list_features",
"family": "file_management",
Expand Down Expand Up @@ -884,6 +905,13 @@
"reason": "",
"summary": "Change one length dimension of the active model, in mm, and rebuild."
},
{
"name": "set_equation",
"family": "equations",
"level": "stable",
"reason": "",
"summary": "Add or change an equation or global variable, so one value drives others (a parametric part)."
},
{
"name": "set_flat_pattern",
"family": "modeling",
Expand All @@ -905,6 +933,13 @@
"reason": "",
"summary": "Set the active drawing sheet's scale, e.g. 1:2; views that use the sheet scale follow it."
},
{
"name": "set_sketch_text",
"family": "sketching",
"level": "stable",
"reason": "",
"summary": "Rewrite the text in a sketch and rebuild, so debossed lettering shows it."
},
{
"name": "set_units",
"family": "modeling",
Expand Down Expand Up @@ -994,11 +1029,11 @@
"com": {
"type_library": "83A33D31-27C5-11CE-BFD4-00400513BB57x0x34x0",
"core": {
"covered": 252,
"covered": 255,
"total": 2838
},
"api": {
"covered": 278,
"covered": 298,
"total": 5985
},
"interfaces": [
Expand Down Expand Up @@ -1071,6 +1106,7 @@
"GetActiveSketch2",
"GetConfigurationNames",
"GetDependencies2",
"GetEquationMgr",
"GetFeatureCount",
"GetLineCount",
"GetMassProperties",
Expand All @@ -1092,6 +1128,7 @@
"InsertRib",
"InsertSketch",
"InsertSketchForEdgeFlange",
"InsertSketchText",
"Lock",
"Parameter",
"Save",
Expand Down Expand Up @@ -1322,7 +1359,8 @@
"GetLineCount",
"GetSketchContours",
"GetSketchPoints2",
"GetSketchSegments"
"GetSketchSegments",
"GetSketchTextSegments"
],
"total": 102
}
Expand Down
14 changes: 7 additions & 7 deletions docs/assets/progress/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading