Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.1.0] - 2026-11-21

### Changed

- **`generate_drawing_package` fits every title-block field** (#158):
Expand Down Expand Up @@ -228,6 +230,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- **`add_fillet` works on SolidWorks 2024** (#255): below 2025 it called
`IFeatureManager.FeatureFillet3` with 15 arguments where the method takes
14, so every fillet failed with "Invalid number of parameters". Every
version now makes the call checked live on 2026.
- **`create_drawing_view` applies `scale`** (#256): the view kept the sheet's
scale and `scale_applied` was always false. A given scale is now the view's
own and is read back; left out, the view uses the sheet's scale. With no
`orientation`, a `view_type` such as `isometric` sets the view instead of
giving a front view.
- **API lookups work when the server starts in a read-only folder** (#257):
the index was saved relative to the working folder, which Claude Desktop
started through `uvx` can't write to. It is now saved in
`~/.solidworks_mcp/docs-index`; an index in the old folder is still read.
- **`construction` is honoured on SolidWorks**: `add_line`, `add_circle`
and `add_rectangle` accepted `construction` but drew normal geometry, while
the reply said `"construction": true`. The tools now set it on the new
Expand Down
8 changes: 4 additions & 4 deletions docs/assets/progress/tool-list-size.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
| `SOLIDWORKS_MCP_TOOLSETS` | `SOLIDWORKS_MCP_TOOL_MODE` | Tools listed | Size | Tokens (estimate) | Of the full list |
| --- | --- | ---: | ---: | ---: | ---: |
| `all` | `list` | 151 | 245 KB | 62,704 | 100% |
| `all` | `list` | 151 | 245 KB | 62,759 | 100% |
| `core` | `list` | 111 | 169 KB | 43,262 | 69% |
| `drawing` | `list` | 21 | 38 KB | 9,616 | 15% |
| `drawing` | `list` | 21 | 38 KB | 9,668 | 15% |
| `automation` | `list` | 3 | 6 KB | 1,556 | 2% |
| `vba` | `list` | 10 | 17 KB | 4,356 | 7% |
| `docs` | `list` | 6 | 15 KB | 3,914 | 6% |
| `core,drawing` | `list` | 132 | 207 KB | 52,877 | 84% |
| `docs` | `list` | 6 | 15 KB | 3,916 | 6% |
| `core,drawing` | `list` | 132 | 207 KB | 52,930 | 84% |
| `all` | `search` | 4 | 4 KB | 908 | 1% |
| `core` | `search` | 4 | 4 KB | 908 | 1% |
4 changes: 2 additions & 2 deletions docs/user-guide/tool-catalog/drawing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Place one named view of a part or assembly on the active drawing sheet.
| `view_type` | `str` | ✅ | `` | Type of view (orthographic, isometric, section, detail) |
| `position_x` | `float` | — | `100.0` | X position in drawing (mm) |
| `position_y` | `float` | — | `200.0` | Y position in drawing (mm) |
| `scale` | `float` | — | `1.0` | View scale factor |
| `orientation` | `str` | — | `front` | View orientation (front, top, right, isometric) |
| `scale` | `float?` | — | `None` | The view's own scale, e.g. `0.5` for 1:2 (`UseSheetScale` off, `ScaleDecimal`, read back as `scale_applied`); left out, the sheet's scale (`set_sheet_scale`) |
| `orientation` | `str?` | — | `None` | View orientation (front, top, right, isometric); left out, a `view_type` that names one is used, else front |

**Sample call:**

Expand Down
2 changes: 2 additions & 0 deletions openspec/changes/solidworks-2024-reports/.openspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-20
55 changes: 55 additions & 0 deletions openspec/changes/solidworks-2024-reports/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## Why

A user on SolidWorks 2024 SP5, installed with `uvx` and run from Claude
Desktop, reported three faults on 2026-11-20 (#255, #256, #257). Each is
ours, and each has gone unseen because every live run so far has been on
SolidWorks 2026 from a developer's checkout:

- **#255** `add_fillet` always fails before 2025: below major version 33 it
calls `IFeatureManager.FeatureFillet3` with 15 arguments, radius first; the
type library's signature has 14, options first. That branch has never run.
- **#256** `create_drawing_view` never changes a view's scale: the view keeps
using the sheet scale (`UseSheetScale` is never turned off), and the reply's
`scale_applied` is always false because it tests `setattr`'s return value.
Also, `view_type` alone never sets the view, because the tool always sends
`orientation` (default `front`).
- **#257** every API lookup fails with `PermissionError` when the server's
working folder isn't writable (Claude Desktop through `uvx`): the index is
saved to a folder relative to it, `.generated/docs-index`.

## What Changes

- `add_fillet` uses `IModelDoc2.FeatureFillet3` (9 arguments) on every
SolidWorks version, the call checked live on 2026; the version check and
the broken branch go.
- `create_drawing_view` turns the view's `UseSheetScale` off, sets
`ScaleDecimal`, and reads it back for `scale_applied`. With no
`orientation`, a `view_type` that names a view (`top`, `isometric`, ...)
sets it.
- The API index is saved in the user's own folder (`~/.solidworks_mcp/
docs-index`, beside the server's other data); the old relative folders are
still read, so an index built there keeps working.

## Capabilities

### New Capabilities

- `tools/drawing-view-scale`: a view's own scale, applied and read back;
`view_type` as the orientation when none is given.

### Modified Capabilities

- `tools/edge-treatment`: a fillet works on every supported SolidWorks
version (an added requirement).
- `tools/api-help-lookup`: the index is saved in a user-writable folder (an
added requirement).

## Impact

- `adapters/solidworks/features.py` (`_add_fillet_impl`),
`adapters/solidworks/io.py` (`_place_view`), `tools/drawing.py`
(`CreateDrawingViewInput`), `tools/docs_discovery.py` (`_INDEX_DIRS`);
tests beside each; the catalog pages; CHANGELOG.
- No public reply on the issues until the user decides (the user's
instruction, 2026-11-20). Each fix is checked live on 2026; 2024 can only
be confirmed by the reporter.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## ADDED Requirements

### Requirement: The index is saved in a folder the user can write to
The API lookups SHALL save a built index in the user's own data folder
(`~/.solidworks_mcp/docs-index`), not a folder relative to the server's
working directory, and SHALL still read an index saved in the old relative
folders.

#### Scenario: Started by Claude Desktop through uvx
- **WHEN** the server's working folder is not writable and
`lookup_api_method` is called
- **THEN** the index is built and saved under `~/.solidworks_mcp/docs-index`
and the lookup answers

#### Scenario: An index from before
- **WHEN** an index already exists in `.generated/docs-index`
- **THEN** lookups read it without rebuilding
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## ADDED Requirements

### Requirement: A view's own scale is applied and read back
`create_drawing_view` with a `scale` SHALL give the new view its own scale
(no longer the sheet's) and reply with `scale_applied` true only when the
scale read back from the view matches. With no `scale` the view SHALL keep
the sheet's scale, so `set_sheet_scale` still governs it.

#### Scenario: A half-scale top view
- **WHEN** a top view is placed with `scale` 0.5
- **THEN** the view is drawn at 1:2 while the sheet keeps its scale, and the
reply says `scale_applied: true`

#### Scenario: A scale SolidWorks doesn't keep
- **WHEN** the view's scale reads back as something else
- **THEN** the reply says `scale_applied: false`

### Requirement: `view_type` names the view when `orientation` is left out
`create_drawing_view` with no `orientation` SHALL use `view_type` as the
orientation when it names one (`front`, `top`, `right`, `isometric`, ...),
and `front` otherwise.

#### Scenario: Only view_type
- **WHEN** a view is placed with `view_type` `isometric` and no
`orientation`
- **THEN** it is an isometric view, not a front view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## ADDED Requirements

### Requirement: A fillet works on every supported SolidWorks version
`add_fillet` SHALL build the fillet with the same COM call on every
SolidWorks version the server supports, so no version takes a branch that
has never run.

#### Scenario: SolidWorks 2024
- **WHEN** `add_fillet` runs against SolidWorks 2024 (major version 32)
- **THEN** it calls `IModelDoc2.FeatureFillet3` with its 9 arguments, as on
2025 and 2026, and adds the fillet
22 changes: 22 additions & 0 deletions openspec/changes/solidworks-2024-reports/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## 1. Fillet on every version (#255)

- [x] 1.1 `_add_fillet_impl`: always `IModelDoc2.FeatureFillet3`; the version check and the `IFeatureManager.FeatureFillet3` branch removed
- [x] 1.2 Tests: a 2024 revision takes the same call; the tests that reached the old branch by giving no version move to the model call

## 2. View scale and view_type (#256)

- [x] 2.1 `_place_view`: `UseSheetScale` off, `ScaleDecimal` set, read back for `scale_applied` (and the scale read back in the reply)
- [x] 2.2 `CreateDrawingViewInput.orientation` defaults to none; `view_type` that names a view is used, else `front`
- [x] 2.3 Tests beside each; the drawing catalog entry

## 3. The index folder (#257)

- [x] 3.1 `_INDEX_DIRS`: `~/.solidworks_mcp/docs-index` first (where an index is saved), then the old relative folders (read only)
- [x] 3.2 Tests: a build saves to the user folder; an old relative index is still found; the catalog and tool description

## 4. Checks and sign-off

- [x] 4.1 Unit suite at 100% coverage, ruff, mypy, mkdocs strict, link check; CHANGELOG
- [x] 4.2 Live on 2026: a fillet, a half-scale view, and a lookup started from a read-only folder
- [ ] 4.3 The user decides what to say on #255, #256, #257 and when; nothing is posted until then (replies drafted 2026-11-20: fixed in the release, then the selftest on 2024)
- [ ] 4.4 After the merge: release 2.1.0 from main (pyproject, version.py, server.json, CHANGELOG heading), tag pushed by the user's OK
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "solidworks-mcp-python"
version = "2.0.0"
version = "2.1.0"
description = "Python MCP server for SolidWorks: lets Claude and other AI agents build parts, assemblies and drawings through the SolidWorks COM API."
# The README with relative links made absolute for PyPI: see the fancy-pypi-readme hook.
dynamic = ["readme"]
Expand Down
4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"source": "github"
},
"websiteUrl": "https://andrewbartels1.com/SolidworksMCP-python/",
"version": "2.0.0",
"version": "2.1.0",
"packages": [
{
"registryType": "pypi",
"identifier": "solidworks-mcp-python",
"version": "2.0.0",
"version": "2.1.0",
"runtimeHint": "uvx",
"transport": {
"type": "stdio"
Expand Down
94 changes: 24 additions & 70 deletions src/solidworks_mcp/adapters/solidworks/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,18 +2102,6 @@ def _fillet_operation() -> SolidWorksFeature:
LookupError: If an edge or face entry selects nothing.
Exception: If the feature is ``None``.
"""
# Detect SW major version for FeatureFillet3 parameter count
fillet_sw_major = 0
if getattr(adapter, "swApp", None):
rev = adapter._attempt(
lambda: adapter._get_attr_or_call(adapter.swApp, "RevisionNumber"),
default="0",
)
try:
fillet_sw_major = int(str(rev).split(".")[0])
except (ValueError, IndexError):
fillet_sw_major = 0

# Only touch the selection when edges/faces were explicitly named.
# An empty edge_names means "use whatever is already selected" --
# e.g. entities the user hand-picked in the live UI via
Expand Down Expand Up @@ -2163,48 +2151,27 @@ def _fillet_operation() -> SolidWorksFeature:
if not selected:
raise LookupError(f"Failed to select edge: {edge_name}")

# SW 2025+ (major >= 33): IModelDoc2.FeatureFillet3 (9 params).
# Returns a non-zero int on success — NOT an IFeature — so we look up
# the last modified feature afterwards to get the name/id.
# Older builds: IFeatureManager.FeatureFillet3 (15 params, returns IFeature).
if fillet_sw_major >= 33:
result_code = adapter.currentModel.FeatureFillet3(
radius / 1000.0, # R1 in meters
True, # Propagate (VT_BOOL)
0, # Ftyp (VT_I4)
False, # VarRadTyp (VT_BOOL — must be bool, not int)
0, # OverflowType (VT_I4)
0, # NRadii (VT_I4)
None, # Radii (VT_VARIANT)
False, # UseHelpPoint (VT_BOOL)
False, # UseTangentHoldLine (VT_BOOL)
)
if not result_code:
raise Exception(
"Failed to create fillet (IModelDoc2.FeatureFillet3 returned 0)"
)
feature = None # int return — retrieve feature object below
else:
feature_manager = adapter.currentModel.FeatureManager
feature = feature_manager.FeatureFillet3(
radius / 1000.0,
0,
0,
0,
0,
False,
False,
False,
False,
False,
False,
False,
False,
0,
False,
# IModelDoc2.FeatureFillet3 (9 params) on every version. It returns a
# non-zero int on success, not an IFeature, so the feature is looked
# up afterwards for its name. (Before #255, versions below 2025 called
# IFeatureManager.FeatureFillet3 with 15 arguments, radius first; its
# signature has 14, options first, so it always failed with
# DISP_E_BADPARAMCOUNT on SolidWorks 2024.)
result_code = adapter.currentModel.FeatureFillet3(
radius / 1000.0, # R1 in meters
True, # Propagate (VT_BOOL)
0, # Ftyp (VT_I4)
False, # VarRadTyp (VT_BOOL — must be bool, not int)
0, # OverflowType (VT_I4)
0, # NRadii (VT_I4)
None, # Radii (VT_VARIANT)
False, # UseHelpPoint (VT_BOOL)
False, # UseTangentHoldLine (VT_BOOL)
)
if not result_code:
raise Exception(
"Failed to create fillet (IModelDoc2.FeatureFillet3 returned 0)"
)
if not feature:
raise Exception("Failed to create fillet")

# IModelDoc2.FeatureFillet3 returns non-zero for a selection it then
# builds nothing from (e.g. a bare face, seen live on SW 2026), so a
Expand All @@ -2223,25 +2190,12 @@ def _fillet_operation() -> SolidWorksFeature:
"edges could not be filleted at this radius."
)

# Resolve the feature name — FeatureFillet3 on SW 2025+ returns an int,
# not an IFeature, so we can only report a default name here.
feature_name = "Fillet"
if feature is not None:
# Not hasattr(): it only swallows AttributeError, so a stale COM
# dispatch raising on Name would fail a fillet that was created.
try:
feature_name = feature.Name or "Fillet"
except Exception: # noqa: BLE001 - int return / stale dispatch
pass

# IModelDoc2.FeatureFillet3 returns an int, not an IFeature, so the
# name is SolidWorks' default; list_features gives the numbered one.
return SolidWorksFeature(
name=feature_name,
name="Fillet",
type="Fillet",
id=(
adapter._attempt(lambda: adapter._get_feature_id(feature), default="")
if feature
else ""
),
id="",
parameters={"radius": radius, "edges": edge_names},
properties={"created": datetime.now().isoformat()},
)
Expand Down
35 changes: 27 additions & 8 deletions src/solidworks_mcp/adapters/solidworks/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,17 @@ def _place_view(self, payload: Any) -> AdapterResult[dict[str, Any]]:
x = float(_first(data, "position_x", "x", default=100.0))
y = float(_first(data, "position_y", "y", default=150.0))

requested = str(_first(data, "orientation", "view_type", default="front"))
# With no orientation, a view_type that names a view ("top",
# "isometric") is the orientation; any other ("orthographic") is front
# (#256: view_type alone used to leave every view a front view).
view_type = str(_first(data, "view_type", default="")).strip().lower()
requested = str(
_first(
data,
"orientation",
default=view_type if view_type in _NAMED_VIEWS else "front",
)
)
view_name = _NAMED_VIEWS.get(requested.strip().lower())
if view_name is None and requested.startswith("*"):
view_name = requested
Expand Down Expand Up @@ -3322,17 +3332,25 @@ def _add() -> dict[str, Any]:
added = [n for n in after if n not in before]
new_view = added[-1] if added else after[-1]

scale_applied = False
# The view's own scale: UseSheetScale off, then ScaleDecimal,
# read back (#256: the view kept the sheet's scale, and
# scale_applied tested setattr's return value, always None).
scale_read = None
if scale and view is not None:
wrapped = _as_com(adapter, view, "IView")
if wrapped is not None:
scale_applied = (
adapter._attempt(
lambda: setattr(wrapped, "ScaleRatio", [scale, 1.0]),
default=None,
)
is not None
adapter._attempt(
lambda: setattr(wrapped, "UseSheetScale", 0), default=None
)
adapter._attempt(
lambda: setattr(wrapped, "ScaleDecimal", scale), default=None
)
scale_read = adapter._attempt(
lambda: float(wrapped.ScaleDecimal), default=None
)
scale_applied = scale_read is not None and math.isclose(
scale_read, scale, rel_tol=1e-6
)

return {
"name": new_view,
Expand All @@ -3341,6 +3359,7 @@ def _add() -> dict[str, Any]:
"position": {"x": x, "y": y},
"scale": scale or None,
"scale_applied": scale_applied if scale else None,
"scale_read": scale_read,
"views_before": len(before),
"views_after": len(after),
}
Expand Down
Loading
Loading