solidworks_mcp.adapters.solidworks.features¶
solidworks_mcp.adapters.solidworks.features ¶
Feature-domain mixin for PyWin32 SolidWorks operations.
Attributes¶
_AXIS_PLANE_PAIRS
module-attribute
¶
_AXIS_PLANE_PAIRS: dict[str, tuple[str, str]] = {'x': ('Top Plane', 'Front Plane'), 'y': ('Front Plane', 'Right Plane'), 'z': ('Top Plane', 'Right Plane')}
_EXTRUSION_END_CONDITIONS
module-attribute
¶
_EXTRUSION_END_CONDITIONS = {'blind': ('Blind', 'swEndCondBlind'), 'midplane': ('MidPlane', 'swEndCondMidPlane'), 'throughall': ('ThroughAll', 'swEndCondThroughAll'), 'uptonext': ('UpToNext', 'swEndCondUpToNext')}
_THIN_SIDES
module-attribute
¶
_TREE_WALK_MEMBERS
module-attribute
¶
Classes¶
AdapterResult
dataclass
¶
AdapterResult(status: AdapterResultStatus, data: T | None = None, error: str | None = None, execution_time: float | None = None, metadata: dict[str, Any] | None = None)
Result wrapper for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
T | None
|
The data value. |
error |
str | None
|
The error value. |
execution_time |
float | None
|
The execution time value. |
metadata |
dict[str, Any] | None
|
The metadata value. |
status |
AdapterResultStatus
|
The status value. |
AdapterResultStatus ¶
Bases: StrEnum
Result status for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
ERROR |
Any
|
The error value. |
SUCCESS |
Any
|
The success value. |
TIMEOUT |
Any
|
The timeout value. |
WARNING |
Any
|
The warning value. |
ExtrusionParameters ¶
Bases: BaseModel
Parameters for extrusion operations.
Attributes:
| Name | Type | Description |
|---|---|---|
auto_select |
bool
|
The auto select value. |
both_directions |
bool
|
The both directions value. |
depth |
float
|
The depth value. |
draft_angle |
float
|
The draft angle value. |
end_condition |
str
|
The end condition value. |
feature_scope |
bool
|
The feature scope value. |
merge_result |
bool
|
The merge result value. |
reverse_direction |
bool
|
The reverse direction value. |
sketch_name |
str | None
|
Explicit sketch to operate on. When set, callers (e.g. create_cut_extrude) must select exactly this sketch and fail with a clear error if it doesn't exist rather than silently falling back to some other sketch. |
thin_feature |
bool
|
The thin feature value. |
thin_thickness |
float | None
|
The thin thickness value. |
thin_side |
str
|
Which side of the sketch a thin wall grows on:
|
up_to_surface |
str | None
|
The up to surface value. |
LoftParameters ¶
Bases: BaseModel
Parameters for loft operations.
Attributes:
| Name | Type | Description |
|---|---|---|
end_tangent |
str | None
|
The end tangent value. |
guide_curves |
list[str] | None
|
The guide curves value. |
merge_result |
bool
|
The merge result value. |
profiles |
list[str]
|
The profiles value. |
start_tangent |
str | None
|
The start tangent value. |
MassProperties ¶
Bases: BaseModel
Mass properties information.
Attributes:
| Name | Type | Description |
|---|---|---|
center_of_mass |
list[float]
|
The center of mass value. |
mass |
float
|
The mass value. |
moments_of_inertia |
dict[str, float]
|
The moments of inertia value. |
principal_axes |
dict[str, list[float]] | None
|
The principal axes value. |
surface_area |
float
|
The surface area value. |
volume |
float
|
The volume value. |
RevolveParameters ¶
Bases: BaseModel
Parameters for revolve operations.
Attributes:
| Name | Type | Description |
|---|---|---|
angle |
float
|
The angle value. |
both_directions |
bool
|
The both directions value. |
merge_result |
bool
|
The merge result value. |
reverse_direction |
bool
|
The reverse direction value. |
thin_feature |
bool
|
The thin feature value. |
thin_thickness |
float | None
|
The thin thickness value. |
sketch_name |
str | None
|
The sketch to revolve, by its tree name;
|
axis_entity |
str | None
|
The axis to revolve about: a sketch line's
id ( |
SolidWorksFeature ¶
Bases: BaseModel
SolidWorks feature information.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str | None
|
The id value. |
name |
str
|
The name value. |
parameters |
dict[str, Any] | None
|
The parameters value. |
parent |
str | None
|
The parent value. |
properties |
dict[str, Any] | None
|
The properties value. |
type |
str
|
The type value. |
SolidWorksFeaturesMixin ¶
Expose SolidWorks feature methods via mixin-local implementation helpers.
Methods:¶
add_fillet
async
¶
Fillet edges, then confirm the model's volume actually changed.
IModelDoc2.FeatureFillet3 can report success without building
anything, so besides the feature-count check inside
:func:_add_fillet_impl the volume is compared before and after,
here in the async layer for the same reason as mirror_feature.
An unreadable volume is not treated as failure. With no edge_names
(the current selection) the volume is not read: see the comment below.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Fillet radius in millimetres. |
required |
edge_names
|
list[str]
|
Edge names, |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The fillet, with |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
could be read. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
create_reference_point
async
¶
create_reference_point(mode: str, x: float, y: float, z: float, distance: float | None = None, percent: float | None = None) -> AdapterResult[dict[str, Any]]
Create a reference point on the active part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
|
required |
x
|
float
|
X of a point on the target edge/face, in millimetres. |
required |
y
|
float
|
Y of a point on the target edge/face, in millimetres. |
required |
z
|
float
|
Z of a point on the target edge/face, in millimetres. |
required |
distance
|
float | None
|
For |
None
|
percent
|
float | None
|
For |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Delegates to |
AdapterResult[dict[str, Any]]
|
func: |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
delete_feature
async
¶
Delete a feature and report every feature that went with it.
The tree is listed before and after with list_features, the read
path that works on SolidWorks, and the names that disappeared become
removed_features: the named feature and its dependents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The feature or sketch to delete. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The delete's data plus |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
can't be listed). |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
mirror_feature
async
¶
mirror_feature(features: list[str], mirror_plane: str, merge: bool = True, mirror_bodies: bool = True) -> AdapterResult[dict[str, Any]]
Mirror solid bodies or features about a plane.
InsertMirrorFeature returns a Feature object even when it mirrored
nothing, so the model's volume is measured before and after and the
call is reported as failed if the volume did not change (a mirrored
cut lowers it, a mirrored boss or body raises it). That check runs
here rather than inside the COM closure because get_mass_properties
is the read path known to work - reading CreateMassProperty().Volume
inline returns None when a plane is still in the selection set,
which silently disables the check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[str]
|
Names of the bodies (or features) to mirror. For a body mirror these are the names as they appear under Solid Bodies, which for a lofted wing is the loft's own name. |
required |
mirror_plane
|
str
|
Plane to mirror about, e.g. |
required |
merge
|
bool
|
Merge the mirrored result with the original. |
True
|
mirror_bodies
|
bool
|
Mirror whole solid bodies rather than features.
Defaults to |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was mirrored, and the volume |
AdapterResult[dict[str, Any]]
|
before, after and its change. |
AdapterResult[dict[str, Any]]
|
the call failed, or the volume did not change. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
pattern_circular
async
¶
pattern_circular(features: list[str], axis: str, count: int, angle: float = 360.0, equal_spacing: bool = True) -> AdapterResult[dict[str, Any]]
Pattern features around an axis.
FeatureCircularPattern5 returns a Feature object whether or not it
produced anything, so the model volume is measured before and after
here - in the async layer, using get_mass_properties, which is the
read path that works. Reading volume inline inside the COM closure
returns None while a selection is active.
Note that instances landing off the parent body are silently dropped
by SolidWorks, so the volume changes by less than count - 1 times
the seed. That is correct behaviour, not a failure - only no change
at all means the pattern did nothing. A pattern of a cut lowers the
volume, a pattern of a boss raises it; both count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[str]
|
Names of the features to pattern. |
required |
axis
|
str
|
Name of the axis to rotate about, e.g. |
required |
count
|
int
|
Total number of instances including the original. |
required |
angle
|
float
|
Total angle in degrees to spread them over. Defaults to a full 360. |
360.0
|
equal_spacing
|
bool
|
Space instances evenly across |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was patterned and the volume |
AdapterResult[dict[str, Any]]
|
before, after and its change. |
AdapterResult[dict[str, Any]]
|
selected or the volume did not change. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
rename_feature
async
¶
Rename a feature on the active model's tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_name
|
str
|
The feature's current name. |
required |
new_name
|
str
|
The name to give it. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Delegates to |
AdapterResult[dict[str, Any]]
|
func: |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
SweepParameters ¶
Bases: BaseModel
Parameters for sweep operations.
Attributes:
| Name | Type | Description |
|---|---|---|
merge_result |
bool
|
The merge result value. |
path |
str
|
The path value. |
twist_along_path |
bool
|
The twist along path value. |
twist_angle |
float
|
The twist angle value. |
_BodyEntityPicker ¶
Find the body edge or face nearest a point, by true closest distance.
SelectByID2("", "EDGE", x, y, z, ...) picks along the view direction
through the point, so on a 12 mm plate seen from the front an edge at
z=-6 is hidden behind the matching edge at z=+6 and the front one is
selected instead - silently. This walks every solid body's edges (or
faces) and measures the distance from the point to the closest point
on each (IEdge / IFace2.GetClosestPointOn), which does not
depend on the view, vertices or midpoints.
The entity lists are read once per picker, so one fillet over many edges costs one body walk, not one per edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
Methods:¶
entities ¶
Return every solid body's GetEdges() or GetFaces().
Source code in src/solidworks_mcp/adapters/solidworks/features.py
nearest ¶
Return (entity, distance_m) for the closest entity, or None.
Source code in src/solidworks_mcp/adapters/solidworks/features.py
select ¶
Select entity with IEntity.Select4 under mark.
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_NullCalloutSentinel ¶
Stand-in for VARIANT(VT_DISPATCH, None) when pywin32 is absent.
Never passed to a real COM call (if pywin32 isn't importable, no live
SolidWorks call can happen either), but must still be distinguishable
from a bare None so callers can't accidentally regress to passing
plain None as SelectByID2's Callout argument.
Functions:¶
_active_in ¶
Whether the active configuration is one of names.
_add_chamfer_impl ¶
_add_chamfer_impl(adapter: Any, distance: float, edge_names: list[str], angle: float = 45.0, flip: bool = False) -> AdapterResult[SolidWorksFeature]
Create an angle-distance chamfer on one or more named edges.
Each edge in edge_names is selected by name using
Extension.SelectByID2 with entity type "EDGE". After all edges
are in the selection set, IFeatureManager::InsertFeatureChamfer is
called with swChamferAngleDistance (type 1; equal distance is
16). At 45 degrees the two legs are equal, which is what this call has
always made. Options 1 is swFeatureChamferFlipDirection, kept as
the default so existing chamfers are unchanged; flip clears it. A version-gated
IModelDoc2::FeatureChamferType path was tried for SW 2025+ but
live-verified to silently create an empty, zero-volume feature -- see
the comment at its call site for how this was confirmed and why
InsertFeatureChamfer is used unconditionally instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
distance
|
float
|
Chamfer distance in millimetres, along one face. Converted to metres internally. |
required |
angle
|
float
|
Chamfer angle in degrees (0-90 exclusive). Defaults to 45. |
45.0
|
flip
|
bool
|
Measure |
False
|
edge_names
|
list[str]
|
List of SolidWorks edge entity names, e.g.
|
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
result = pywin32_feature_ops.add_chamfer(
adapter, distance=2.0, edge_names=["Edge<2>"]
)
print(result.data.name) # e.g. "Chamfer1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 | |
_add_fillet_impl ¶
_add_fillet_impl(adapter: Any, radius: float, edge_names: list[str]) -> AdapterResult[SolidWorksFeature]
Create a constant-radius fillet on one or more named edges.
Each edge in edge_names is selected by name using
Extension.SelectByID2 with entity type "EDGE". After all edges
are in the selection set, FeatureFillet3 is called to build the
feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
radius
|
float
|
Fillet radius in millimetres. Converted to metres internally before the COM call. |
required |
edge_names
|
list[str]
|
List of SolidWorks edge entity names to fillet, e.g.
|
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
result = pywin32_feature_ops.add_fillet(
adapter, radius=3.0, edge_names=["Edge<1>", "Edge<3>"]
)
print(result.data.name) # e.g. "Fillet1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 | |
_attempt ¶
Run fn through the adapter's _attempt (exceptions -> default).
_create_axis_impl ¶
Create a reference axis along a principal direction.
Wraps IModelDoc2::InsertAxis2(AutoSize) - note the interface: it is on
IModelDoc2, not IFeatureManager. It builds an axis from two
selected planes, so an axis is requested by naming the direction and the
matching plane pair is selected here.
InsertAxis2 returns a plain boolean rather than the axis, so success is
confirmed by the feature count rising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
reference
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The planes used and how the tree |
AdapterResult[dict[str, Any]]
|
changed. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 | |
_create_cut_extrude_impl ¶
_create_cut_extrude_impl(adapter: Any, params: ExtrusionParameters) -> AdapterResult[SolidWorksFeature]
Create a cut-extrude feature from an explicit or unambiguously-tracked sketch.
Sketch resolution never guesses:
params.sketch_name, if given, is matched (case-insensitively) against the live feature tree via :func:_profile_feature_names. No match -> immediate error listing the sketches that do exist. No COM cut is attempted.- Otherwise,
adapter._last_sketch_name(set by the most recentcreate_sketch/exit_sketchcall in this session) is used only if it also matches a real name in the current tree — this catches the case wherecreate_sketchhad to fall back to a syntheticSketch_Nguess (SolidWorks didn't hand back a usable sketch object synchronously) and that guess doesn't correspond to anything real. - Otherwise: immediate error asking the caller to pass
sketch_nameexplicitly, listing available sketches. There is no third guess (no "most recentProfileFeaturein the tree", no blindSketch<N>enumeration) — a wrong silent guess would cut the wrong profile.
Once resolved, the sketch is explicitly selected via SelectByID2
before any FeatureCut call — SolidWorks' own "implicit" active-sketch
state (whatever was last open before this call) is never relied upon,
since that is exactly the racy behavior that made this feature
intermittently cut nothing.
Two COM API variants are attempted in order of preference:
FeatureCut4— most modern (SolidWorks 2015+).FeatureCut3— SolidWorks 2010–2014, and any install lackingFeatureCut4. Same 26-parameter order asFeatureCut4minus the trailingOptimizeGeometryargument (confirmed against SolidWorks API help and live macro examples — there is no separate "legacy" argument order; an earlier version of this fallback invented one and it always raisedDISP_E_PARAMNOTOPTIONALbecause it was missing theNormalCutargument and hadD2missing entirely).
All depth values are in millimetres and converted to metres internally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
params
|
ExtrusionParameters
|
Extrusion parameter bag reused for cut parameters:
- |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
failure, |
AdapterResult[SolidWorksFeature]
|
which stage failed: sketch-not-found (with the list of sketches that |
AdapterResult[SolidWorksFeature]
|
do exist), sketch-selection-failed (the resolved name plus why |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
own error text — and, when every COM call returned falsy without |
AdapterResult[SolidWorksFeature]
|
raising at all, an explicit note that the profile likely isn't a |
AdapterResult[SolidWorksFeature]
|
valid closed loop intersecting solid geometry, rather than a bare |
AdapterResult[SolidWorksFeature]
|
"failed" with no diagnostic content. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
from solidworks_mcp.adapters.base import ExtrusionParameters
from solidworks_mcp.adapters import pywin32_feature_ops
params = ExtrusionParameters(depth=10.0, end_condition="ThroughAll")
result = pywin32_feature_ops.create_cut_extrude(adapter, params)
print(result.data.name) # e.g. "Cut-Extrude1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 | |
_create_extrusion_impl ¶
_create_extrusion_impl(adapter: Any, params: ExtrusionParameters) -> AdapterResult[SolidWorksFeature]
Create a boss-extrude feature from the active sketch profile.
Attempts the modern FeatureExtrusion3 COM call first; falls back to the
legacy FeatureExtrusion2 signature when the newer overload is absent.
When params.thin_feature is truthy, the thin-wall variants
(FeatureExtrusionThin2 / FeatureExtruThin2) are used instead.
All depth and thickness values are provided in millimetres and converted to metres internally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
params
|
ExtrusionParameters
|
Extrusion parameter bag. Relevant fields:
- |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
from solidworks_mcp.adapters.base import ExtrusionParameters
from solidworks_mcp.adapters import pywin32_feature_ops
params = ExtrusionParameters(depth=25.0, draft_angle=2.0)
result = pywin32_feature_ops.create_extrusion(adapter, params)
print(result.data.name) # e.g. "Boss-Extrude1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | |
_create_loft_impl ¶
Create a lofted boss/protrusion between two or more profile sketches.
Uses IFeatureManager::InsertProtrusionBlend2. Each profile named in
params.profiles is selected under mark 1 (in order — the selection
order determines the loft direction), and any params.guide_curves are
selected under mark 2. Because a solid is produced, every profile must be
a closed contour.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
params
|
LoftParameters
|
Loft parameter bag. Relevant fields:
- |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
from solidworks_mcp.adapters.base import LoftParameters
params = LoftParameters(profiles=["Sketch1", "Sketch2"])
result = await adapter.create_loft(params)
print(result.data.name) # e.g. "Loft1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 | |
_create_reference_plane_impl ¶
_create_reference_plane_impl(adapter: Any, reference: str, offset: float, angle: float, flip: bool, axis: str | None = None, face_point: list[float] | None = None) -> AdapterResult[dict[str, Any]]
Create a reference plane offset from, angled to, or on a plane or face.
Wraps IFeatureManager::InsertRefPlane(FirstConstraint,
FirstConstraintAngleOrDistance, Second, value, Third, value). The
reference (a named plane, or the flat face at face_point) is selected
under mark 0; for an angled plane, axis is selected under
mark 1 with the Coincident constraint, which is the second reference
an angled plane needs (an angle constraint on one plane alone adds
nothing, measured on SW 2025).
create_sketch accepts a plane by its tree name, so the name returned
here can be passed straight to it - verified live: a plane 76.2 mm off
the Front Plane came back as "Plane1", and a circle sketched on it
extruded to exactly the expected volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
reference
|
str
|
Name of the reference plane; ignored when |
required |
offset
|
float
|
Offset distance in millimetres, converted to metres. |
required |
angle
|
float
|
Angle in degrees about |
required |
flip
|
bool
|
Reverse the offset or angle direction. |
required |
axis
|
str | None
|
Named axis to rotate about (e.g. |
None
|
face_point
|
list[float] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new plane's name and the parameters |
AdapterResult[dict[str, Any]]
|
used. |
AdapterResult[dict[str, Any]]
|
selected, or no plane was added to the tree. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
plane = await adapter.create_reference_plane("Top Plane", angle=40, axis="Axis1")
await adapter.create_sketch(plane.data["name"])
Source code in src/solidworks_mcp/adapters/solidworks/features.py
3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 | |
_create_reference_point_impl ¶
_create_reference_point_impl(adapter: Any, mode: str, x: float, y: float, z: float, distance: float | None, percent: float | None) -> AdapterResult[dict[str, Any]]
Create a reference point on the active part.
Two modes:
"along_curve"- selects the edge under the millimetre coordinate(x, y, z)and places a pointdistancemm, orpercent(0-100) of the edge length, from the edge start."face_center"- selects the face under(x, y, z)and places a point at its centroid.
Coordinate selection uses IModelDocExtension::SelectByID2; per this
repo's runbook a ForceRebuild3 is issued first so freshly created
edges are tessellated, and the Callout argument is passed an explicit
VT_DISPATCH null. InsertReferencePoint returns a Feature whether
or not it produced anything, so the feature count is compared before and
after.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
mode
|
str
|
|
required |
x
|
float
|
X of a point on the target edge/face, in millimetres. |
required |
y
|
float
|
Y of a point on the target edge/face, in millimetres. |
required |
z
|
float
|
Z of a point on the target edge/face, in millimetres. |
required |
distance
|
float | None
|
For |
required |
percent
|
float | None
|
For |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The mode, the coordinate and resolved |
AdapterResult[dict[str, Any]]
|
parameter, and how the feature tree changed. |
AdapterResult[dict[str, Any]]
|
mode, a bad distance/percent combination, a failed selection, or when |
AdapterResult[dict[str, Any]]
|
no new feature appeared. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 | |
_create_revolve_impl ¶
Create a revolve feature from the active sketch profile around a centre axis.
Uses FeatureRevolve2 from the SolidWorks COM API. The sketch must
already contain a centre-line that SolidWorks will use as the rotation axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
params
|
RevolveParameters
|
Revolve parameter bag. Relevant fields:
- |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
from solidworks_mcp.adapters.base import RevolveParameters
from solidworks_mcp.adapters import pywin32_feature_ops
params = RevolveParameters(angle=360.0, merge_result=True)
result = pywin32_feature_ops.create_revolve(adapter, params)
print(result.data.name) # e.g. "Revolve1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 | |
_create_sweep_impl ¶
Create a swept boss/protrusion from a profile sketch along a path sketch.
Uses IFeatureManager::InsertProtrusionSwept4. Two sketches are
required in the active part: a closed profile sketch and an open
path sketch named by params.path. The path is selected under
mark 4 and the profile under mark 1, per the SolidWorks selection-mark
contract for sweeps.
Because :class:SweepParameters only names the path, the profile is
inferred as the first ProfileFeature sketch in the feature tree whose
name is not the path. In the common "draw profile, draw path, sweep"
workflow this is unambiguous (exactly two sketches exist).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A fully connected |
required |
params
|
SweepParameters
|
Sweep parameter bag. Relevant fields:
- |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: On success, |
AdapterResult[SolidWorksFeature]
|
|
AdapterResult[SolidWorksFeature]
|
|
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Example::
from solidworks_mcp.adapters.base import SweepParameters
params = SweepParameters(path="Sketch2", merge_result=True)
result = await adapter.create_sweep(params)
print(result.data.name) # e.g. "Sweep1"
Source code in src/solidworks_mcp/adapters/solidworks/features.py
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 | |
_delete_feature_impl ¶
Delete a named feature or sketch from the active model.
Selects the feature, then removes it with
IModelDocExtension::DeleteSelection2(swDelete_Children), which takes
the features built on it too ("erase this and what depends on it"), so
the number of features removed is reported, not assumed to be one.
IModelDoc2::EditDelete left a sketch in place when a cut used it
(measured on SolidWorks 2026). A feature's own sketch is "absorbed", not
a child, so deleting a cut leaves its sketch. A sketch a feature uses
can't be deleted on its own at all, so its users are deleted instead,
taking it with them (:func:_delete_users_of).
Success is confirmed by the feature being absent from the tree afterwards, not by the call's return value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
name
|
str
|
Name of the feature or sketch to delete. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was deleted and how the tree |
AdapterResult[dict[str, Any]]
|
changed. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 | |
_delete_users_of ¶
Delete the features built from feature, with their absorbed sketch.
SolidWorks won't delete a sketch a feature still uses: DeleteSelection2
returns False even with swDelete_Children (measured on 2026). Deleting
the features that use it (IFeature::GetChildren) with
swDelete_Absorbed takes the sketch with them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
feature
|
Any
|
The |
required |
Returns:
| Type | Description |
|---|---|
Any
|
tuple[Any, Exception | None]: |
Exception | None
|
what it raised; |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_extrusion_end_condition ¶
_extrusion_end_condition(adapter: Any, end_condition: str, both_directions: bool) -> tuple[str, int]
Resolve a boss extrusion's first-direction end condition.
both_directions=True means mid-plane whatever end_condition says,
which is what the thin-wall branch always did. Before this was shared,
the solid branch passed swEndCondBlind unconditionally, so a
"both directions" extrusion silently came out one-sided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
Adapter whose |
required |
end_condition
|
str
|
Requested condition, e.g. |
required |
both_directions
|
bool
|
Extrude symmetrically about the sketch plane. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, int]
|
tuple[str, int]: The canonical name and its |
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_feature_count ¶
Return how many features the active model has, or None.
Used to confirm an edit changed the tree rather than trusting a COM call that reports success without doing anything.
IFeatureManager::GetFeatureCount is used rather than walking
FirstFeature/GetNextFeature: the walk needs each dispatch flagged
for IFeature before Name and GetNextFeature resolve, and on
SW 2025 it still yields nothing, while the count is a single reliable
call. FeatureByPositionReverse was measured returning nothing usable
on the same document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The feature count, or |
int | None
|
which is deliberately distinct from |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_flag ¶
Flag just names as methods on obj (no-op for None/fakes).
Flagging a whole interface costs ~27 ms per fresh dispatch (see
WALK_MEMBERS in feature_walk); SolidWorks hands back a fresh
dispatch on most calls, so flag only what is about to be read.
Source code in src/solidworks_mcp/adapters/solidworks/com_utils.py
_flag_feature_members ¶
Flag only the named members on obj.
Cheaper than :func:_flag_feature_methods inside a loop: flagging a
whole interface (IFeature is ~100 names, ~27 ms) costs a fixed price
per object, and sw_type_info's flag cache is keyed by id(obj), so
a walk over fresh dispatches — one per feature — never hits it. Flagging
just the handful of members about to be read avoids that cost.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The COM object (or test double) to flag. |
required |
*names
|
str
|
Member names about to be read. |
()
|
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_flag_feature_methods ¶
Best-effort method flagging for a COM object via sw_type_info.
Flagging tells pywin32 late binding to resolve names like GetTypeName2
/ GetNextFeature / FirstFeature as methods. No-ops on plain test
doubles (and any environment without the gen_py wrapper).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The COM object (or test double) to flag. |
required |
interface
|
str
|
SolidWorks interface name (e.g. |
required |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_is_suppressed ¶
Return a feature's suppression state, or None when unreadable.
None is deliberately distinct from False: it means the state could
not be read, which is not evidence that the feature is unsuppressed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter. |
required |
feature
|
Any
|
An |
required |
Returns:
| Type | Description |
|---|---|
bool | None
|
bool | None: |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_mirror_feature_impl ¶
_mirror_feature_impl(adapter: Any, features: list[str], mirror_plane: str, merge: bool, mirror_bodies: bool) -> AdapterResult[dict[str, Any]]
Select the sources and the plane, then call InsertMirrorFeature.
Wraps IFeatureManager::InsertMirrorFeature(BMirrorBody,
BGeometryPattern, BMerge, BKnit). There is no ...2 overload of this
call. Everything it acts on must be pre-selected under the right mark, so
the marks are the whole game - see _MIRROR_MARK_*.
Whether the mirror actually produced geometry is checked by the caller,
which can read volume through get_mass_properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
features
|
list[str]
|
Body or feature names to mirror. |
required |
mirror_plane
|
str
|
Plane name to mirror about. |
required |
merge
|
bool
|
Merge the result with the original. |
required |
mirror_bodies
|
bool
|
Select and mirror whole bodies rather than features. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The mirror feature's name and inputs. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 | |
_new_axis_name ¶
The name of the axis that isn't among before.
The tree is compared by name rather than read at a position: an
assembly keeps its Mates folder (and may place new reference geometry)
away from the end of the tree. A new RefAxis is preferred; otherwise
the only new feature, if there is exactly one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
The connected adapter. |
required |
before
|
set[str]
|
Every feature name before the axis was made. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The axis's name, or None when it can't be told apart. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_null_callout ¶
Return a VT_DISPATCH null for SelectByID2's Callout parameter.
A plain Python None marshals as VT_NULL, which SolidWorks rejects
with DISP_E_TYPEMISMATCH - measured as
(-2147352571, 'Type mismatch.', None, 8). See runbook item 11.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A |
Any
|
when pywin32 is unavailable (mock/Linux runs, where no real COM call |
|
Any
|
will be made anyway, but the value must still never be bare |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_offset_plane_distance ¶
Resolve an offset-plane Distance constraint to (distance_m, flip_bits).
IFeatureManager.InsertRefPlane's Distance constraint takes a positive
magnitude; the side of the base plane is chosen by the OptionFlip
bit, not by the sign of the distance. Passing a negative distance does
not place the plane on the opposite side - SolidWorks clamps it to 0,
collapsing the new plane onto the base. So a negative offset_mm must
be converted to a positive magnitude with the flip bit toggled relative
to the caller's flip request (a negative offset plus flip=True
cancel out).
Credit: this fix (and the pure-helper extraction for direct unit
coverage) ports the sign-resolution logic independently found and fixed
by contributor @pedropaulovc in their fork (commit 3c091fd). See
issue #84.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset_mm
|
float
|
Signed offset from the base plane, in millimetres. |
required |
base_flip
|
bool
|
Whether the caller requested |
required |
Returns:
| Type | Description |
|---|---|
float
|
tuple[float, int]: A non-negative distance in metres, and the flip |
int
|
bits ( |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_parse_edge_spec ¶
Parse an edge/face specification string into (name, x, y, z, entity_type).
Supports three formats:
- "Edge<1>" — name-based EDGE selection (x=y=z=0.0, SW looks up by
topology name)
- "x,y,z" — coordinate-based EDGE selection (name="", coordinate hint
in metres)
- "face:x,y,z" (case-insensitive prefix) — coordinate-based FACE
selection. Selecting a whole face and handing it to
InsertFeatureChamfer/FeatureFillet3 chamfers/fillets every
edge bounding that face in one call. It is the robust way to reach a
hole's rim: the rim is one edge of the face the hole opens onto, and
a point well inside that face is clear of every boundary, whereas an
edge point has to land on the rim itself.
Every coordinate pick must lie within _PICK_TOLERANCE_M of the edge
or face it resolves to. (A 2026-09-18 note here said an edge pick aimed
at a hole rim landed on a 30 mm outer edge; the test's point was on that
outer edge, because it assumed the wrong height axis. See #199.)
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_pattern_circular_impl ¶
_pattern_circular_impl(adapter: Any, features: list[str], axis: str, count: int, angle: float, equal_spacing: bool) -> AdapterResult[dict[str, Any]]
Select the axis and features, then call FeatureCircularPattern5.
This build exposes FeatureCircularPattern through ...5; v5 is used, with
the 14 arguments it declares. DName is a direction name string, so
the axis is both selected under mark 1 and named in the call.
Whether anything was produced is checked by the caller, which can read
volume through get_mass_properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
features
|
list[str]
|
Feature names to pattern. |
required |
axis
|
str
|
Axis name to rotate about. |
required |
count
|
int
|
Total instances including the original. |
required |
angle
|
float
|
Total spread in degrees. |
required |
equal_spacing
|
bool
|
Space instances evenly across |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The pattern's name and inputs. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 | |
_profile_feature_names ¶
Return sketch (ProfileFeature) names in feature-tree order.
Walks FirstFeature -> GetNextFeature reading GetTypeName2 and
collecting features whose type is "ProfileFeature" (a 2D/3D sketch).
Mirrors the tree walk used by :func:_create_cut_extrude_impl, but flags
each feature for IFeature and reads members through
:func:_read_member so it is robust to pywin32's method-vs-property
late-binding ambiguity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: Bare sketch names, earliest first. Empty when the walk |
list[str]
|
finds no sketches or the tree is inaccessible. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_read_member ¶
Read a COM member that pywin32 may expose as a property or a method.
Late-bound pywin32 dispatches are inconsistent: an unflagged zero-arg
accessor may come back as a bound method (needing a call) or as the
already-resolved value — and when that value is itself a COM object it is
also callable, so a naive "call if callable" check wrongly invokes its
default dispatch (Member not found). This helper calls the member and
falls back to the raw member if the call raises, so it yields the value in
every case (flagged method, unflagged method, property-returning-object,
or plain test double).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The COM object (or test double) to read from. |
required |
name
|
str
|
Member name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The member's value, or |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_removed_names ¶
_removed_names(before: AdapterResult[list[dict[str, Any]]], after: AdapterResult[list[dict[str, Any]]]) -> list[str]
The feature names listed before a delete and missing after it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
before
|
AdapterResult[list[dict[str, Any]]]
|
|
required |
after
|
AdapterResult[list[dict[str, Any]]]
|
|
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: The names that went, in tree order; empty when either |
list[str]
|
listing failed. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_rename_feature_impl ¶
Rename a named feature in the active model.
IFeature::Name is a settable property, not a method - it is assigned
directly, never called (see the property-vs-method flagging note in the
COM threading section of CLAUDE.md). SolidWorks silently refuses a
rename onto a name another feature already uses, so a clash is checked
for first and the new name is read back afterwards; a mismatch is
reported as a failure rather than a quiet success.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
old_name
|
str
|
The feature's current name. Any |
required |
new_name
|
str
|
The name to give it. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
names are the same. |
AdapterResult[dict[str, Any]]
|
absent, the target name is taken, or the rename did not take. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 | |
_resolve_profile_sketch ¶
Find the sketch a feature is built from, and select it.
Sketch resolution never guesses: sketch_name is matched against the
live feature tree without regard to case; without it, the sketch the
session closed last is used only if that name is really in the tree.
Anything else raises, listing the sketches that exist. The sketch is then
selected with SelectByID2 so the feature call never relies on
SolidWorks' implicit active-sketch state. Runs inside the caller's
_handle_com_operation closure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
sketch_name
|
str | None
|
The sketch to use, or |
required |
purpose
|
str
|
How the error messages name the use, e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The sketch's name as the tree spells it. |
Raises:
| Type | Description |
|---|---|
Exception
|
The sketch isn't in the tree, or can't be selected. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 | |
_select_by_view_pick ¶
_select_by_view_pick(adapter: Any, x: float, y: float, z: float, append: bool, mark: int, entity_type: str) -> bool
Fallback pick through SelectByID2 when no body geometry is readable.
Tries the point plus small radial/Y offsets. View-dependent (see
:class:_BodyEntityPicker), so only used when the body walk found
nothing to measure.
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_edge_by_coord ¶
_select_edge_by_coord(adapter: Any, x: float, y: float, z: float, append: bool, mark: int = 0, entity_type: str = 'EDGE', picker: _BodyEntityPicker | None = None, rebuild: bool = True) -> bool
Select the edge (or face) nearest to (x, y, z) in metres.
Calls ForceRebuild3 on the first entity in the selection set so that
recent features are fully tessellated and selectable, then resolves the
point with :class:_BodyEntityPicker - the entity whose closest point is
nearest, independent of the view. Only when no body edge/face can be read
at all does it fall back to the view-dependent SelectByID2 pick.
entity_type is normally "EDGE", but pass "FACE" to select a
whole face instead. Any other type ("VERTEX" from
measure_entities) goes straight to the SelectByID2 pick: a vertex
lies on its edges at distance 0, so the edge walk would select an edge
in its place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
x
|
float
|
X in metres. |
required |
y
|
float
|
Y in metres. |
required |
z
|
float
|
Z in metres. |
required |
append
|
bool
|
Add to the current selection instead of replacing it. |
required |
mark
|
int
|
Selection mark. |
0
|
entity_type
|
str
|
|
'EDGE'
|
picker
|
_BodyEntityPicker | None
|
Reuse a picker (and its body walk) across several picks. |
None
|
rebuild
|
bool
|
Rebuild before the first pick. Pass False inside an open sketch: a rebuild there closes the sketch (seen live). |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if an entity was selected; False otherwise. |
Raises:
| Type | Description |
|---|---|
LookupError
|
When the nearest entity is further than
|
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 | |
_select_face_at_point ¶
Select the planar face of the active part at point_mm under mark.
The face is found as select_face_edges finds it (the face whose
closest point is within 0.01 mm), then selected with IEntity.Select4
and a SelectData carrying the mark InsertRefPlane reads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a part open. |
required |
point_mm
|
list[float]
|
|
required |
mark
|
int
|
Selection mark for this reference. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the face was selected. |
Raises:
| Type | Description |
|---|---|
LookupError
|
When no face lies at the point, or the face isn't flat. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_face_edges_by_coord ¶
_select_face_edges_by_coord(adapter: Any, x: float, y: float, z: float, append: bool, picker: _BodyEntityPicker) -> bool
Select every edge bounding the face through (x, y, z) in metres.
IModelDoc2.FeatureFillet3 (SW 2025+) given a selected face returns
success but builds nothing - no feature, no volume change (seen live on
SW 2026). Expanding the face to its edges first gives it what it can
fillet.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the face was found and all of its edges selected. |
Raises:
| Type | Description |
|---|---|
LookupError
|
When no face lies within |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_feature_by_name ¶
Select a feature or sketch by name and return it.
Resolves the entity with IModelDoc2::FeatureByName and selects it with
IFeature::Select2(append, 0) - the same path used elsewhere in this
adapter. SelectByID2 is avoided here because it needs an entity-type
string that differs between sketches and solid features, and because its
Callout argument raises Type mismatch unless passed an explicit
VT_DISPATCH null. Any name@document qualifier is stripped first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
name
|
str
|
Feature or sketch name, e.g. |
required |
append
|
bool
|
Add to the current selection instead of clearing it first. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The selected |
Any
|
could not be selected. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_named_feature ¶
Select a named feature under a specific selection mark via Select2.
Sweep and loft rely on selection marks to tell SolidWorks which selection
is the profile (1), guide curve (2), or sweep path (4). We resolve the
feature with IModelDoc2::FeatureByName and select it with
IFeature::Select2(append, mark) — the same proven path the rest of the
adapter uses for plane/sketch selection. IModelDocExtension::SelectByID2
is avoided deliberately: late-bound SelectByID2 raises
Type mismatch on some SolidWorks builds, whereas FeatureByName +
Select2 is reliable, works for sketches and reference curves such as
a helix, and needs no entity-type string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
name
|
str
|
Feature name (e.g. |
required |
mark
|
int
|
Selection mark — 1=profile, 2=guide curve, 4=sweep path. |
required |
append
|
bool
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_reference_entity ¶
Select a named plane or planar face under a given selection mark.
Prefers FeatureByName + IFeature::Select2, which is reliable
across builds, and falls back to SelectByID2 for planar faces that are
not named tree features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
reference
|
str
|
Plane or face name, e.g. |
required |
mark
|
int
|
Selection mark the SolidWorks call expects for this role. |
required |
append
|
bool
|
Add to the current selection rather than replacing it. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the entity was selected. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_revolve_inputs ¶
Select a revolve's sketch and axis when they are named.
With neither named, nothing is selected: the sketch exit_sketch just
closed and its centreline are used, as before. A named axis needs the
sketch selected first (mark 0), then the axis appended with mark 4, the
mark FeatureRevolve2 reads the axis from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
params
|
RevolveParameters
|
The revolve's parameters. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The sketch's tree name, or |
Raises:
| Type | Description |
|---|---|
Exception
|
The sketch or the axis isn't in the model. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_select_sketch_axis ¶
Append the sketch line axis (an id add_centerline returned)
to the selection with mark 4, the mark FeatureRevolve2 reads its axis
from, as the reference axis is.
The sketch is closed by now: exit_sketch kept its ids in
_closed_sketch, and they only count when the revolved sketch is that
one (every sketch numbers its ids from 1). The line is selected by its
name in the closed sketch: "Line1@Sketch1" as EXTSKETCHSEGMENT
(SKETCHSEGMENT returns False once the sketch is closed; both seen
live on 2026).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter; its |
required |
axis
|
str
|
The name the caller gave. |
required |
sketch
|
str
|
The revolved sketch's tree name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
bool
|
|
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_suppress_feature_impl ¶
_suppress_feature_impl(adapter: Any, name: str, suppress: bool, configurations: str | list[str] = 'this') -> AdapterResult[dict[str, Any]]
Suppress or unsuppress a named feature in the active model.
Suppressing rolls a feature and its children out of the model without deleting it - the reversible way to turn off a bad feature.
EditSuppress2 and EditUnsuppress2 report through the error channel
only, so the resulting state is read back from IFeature::IsSuppressed
rather than inferred from the call returning quietly. "all" or a list
of configurations uses IFeature.SetSuppression2(state, option, names)
instead; the read-back is then the active configuration's state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
name
|
str
|
Feature name to toggle. |
required |
suppress
|
bool
|
|
required |
configurations
|
str | list[str]
|
|
'this'
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The feature and its state afterwards. |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
which is not the same as "not suppressed". |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 | |
_tree_features ¶
Every feature's (type, name) in feature-tree order.
Walks FirstFeature -> GetNextFeature; a feature whose type or
name can't be read is left out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
list[tuple[str, str]]: |
list[tuple[str, str]]
|
first. Empty when the tree is inaccessible. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_undo_impl ¶
Undo the last count operations in the active model.
IModelDoc2::EditUndo2(Steps) is a Sub - it returns nothing - so a
quiet call means only that it was made, not that anything was undone.
SolidWorks accepts an undo with an empty stack without complaint. The
feature tree is therefore compared before and after, and the payload says
plainly whether it changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a valid |
required |
count
|
int
|
Number of operations to undo; values below 1 are clamped. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: How many steps were requested and |
AdapterResult[dict[str, Any]]
|
whether the feature tree actually changed. |
Raises:
| Type | Description |
|---|---|
Exception
|
Propagated through |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
_with_volume_change ¶
_with_volume_change(result: AdapterResult[dict[str, Any]], before: float, after: float) -> AdapterResult[dict[str, Any]]
A pattern or mirror's result, with the volume it changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
AdapterResult[dict[str, Any]]
|
The feature call's successful result. |
required |
before
|
float
|
The part's volume before, in mm³. |
required |
after
|
float
|
The part's volume after, in mm³. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
cut) and |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
as_list ¶
Normalise a COM array/scalar/None return into a list.
configuration_scope ¶
Where a change applies: the COM option, the names, and their array.
"this" is the active configuration, "all" every one, a list those
named (each checked first).
Raises:
| Type | Description |
|---|---|
LookupError
|
For a name the model doesn't have, listing the names. |
Source code in src/solidworks_mcp/adapters/solidworks/configurations.py
entity_name ¶
The document's own name for a default plane or the origin.
Front, Top, Right, XY, XZ, YZ, Front Plane...
and Origin, in any case, are found by their place in the tree; a
@component@assembly suffix reads that component's tree and is kept.
Any other name is returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected adapter with a document open. |
required |
name
|
str
|
The name a tool was given. |
required |
owner
|
Any
|
The document or component to read; by default the active document, or the component the suffix names. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name to pass to SolidWorks. When the tree can't be read, the |
str
|
English name ( |
Raises:
| Type | Description |
|---|---|
LookupError
|
The tree reached its origin with fewer than three reference planes before it; the message lists them and the install's language. |
Source code in src/solidworks_mcp/adapters/solidworks/default_entities.py
reference_plane_refusal ¶
reference_plane_refusal(reference: str, offset: float, angle: float, axis: str | None, face_point: list[float] | None) -> str | None
Why a reference-plane request can't be made, or None when it can.
Shared by the live and mock adapters so both refuse the same requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
Named reference plane (unused with |
required |
offset
|
float
|
Offset in mm. |
required |
angle
|
float
|
Angle in degrees. |
required |
axis
|
str | None
|
Axis to rotate about, for an angle. |
required |
face_point
|
list[float] | None
|
Point on a flat face to use as the reference. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The refusal message, or None. |
Source code in src/solidworks_mcp/adapters/solidworks/features.py
selection_count ¶
Number of entities currently selected in model, or None.