solidworks_mcp.adapters.solidworks.selection¶
solidworks_mcp.adapters.solidworks.selection ¶
Feature selection mixin for PyWin32 SolidWorks operations.
Attributes¶
_SELECTED_ENTITY_TYPE_NAMES
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. |
FaceEdgeSelector ¶
Resolve a face on the active part and multi-select its edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
A connected |
required |
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
Methods:¶
component_faces ¶
Return every face of a component's solid bodies.
Measured on SW 2026: these faces report their geometry in the
component's own part coordinates, wherever it sits in the assembly,
and IEntity::GetComponent on them returns the component.
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
edges ¶
Return (edge, description) for the faces' edges passing the filter.
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
face_at_point ¶
Return the face containing point_mm (closest within 0.01 mm).
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
faces ¶
Return every face of every solid body on the active part.
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
plane_geometry ¶
Return (origin, normal) of a named reference plane.
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
resolve ¶
Resolve the request to one face (or several for plane).
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
select ¶
Select every edge; return the selection count afterwards.
All or nothing: if any edge refuses to select, the selection is
cleared before raising, so a following add_chamfer /
add_fillet with empty edge_names cannot silently act on a
partial set.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
When any edge refuses to select. |
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
SolidWorksSelectionMixin ¶
Expose feature-selection and feature-list methods through a mixin.
Methods:¶
get_selected_entities
async
¶
Report the faces/edges/vertices currently highlighted in the live SolidWorks UI, so an agent can see exactly what the user clicked on instead of guessing from a screenshot (see com-api-pitfalls.md #21 for why a screenshot alone is not reliable proof of document/view state).
Refreshes currentModel from swApp.ActiveDoc first, the same
way list_features does, since the user's selection lives on
whatever document is actually active in the UI right now -- which
may not be the document this adapter last created or touched.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: One entry per selected |
AdapterResult[list[dict[str, Any]]]
|
entity, each with at least |
AdapterResult[list[dict[str, Any]]]
|
( |
AdapterResult[list[dict[str, Any]]]
|
additionally carry |
AdapterResult[list[dict[str, Any]]]
|
|
AdapterResult[list[dict[str, Any]]]
|
|
AdapterResult[list[dict[str, Any]]]
|
(the true length of a curved edge will be longer). Vertices |
AdapterResult[list[dict[str, Any]]]
|
carry |
AdapterResult[list[dict[str, Any]]]
|
omitted rather than failing the whole call -- a partial |
AdapterResult[list[dict[str, Any]]]
|
description is more useful than none. |
Source code in src/solidworks_mcp/adapters/solidworks/selection.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 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 | |
select_face_edges
async
¶
select_face_edges(point: list[float] | None = None, side: str | None = None, plane: str | None = None, edge_type: str = 'all', append: bool = False) -> AdapterResult[dict[str, Any]]
Multi-select every edge bounding one face of the active part.
See SolidWorksAdapter.select_face_edges for the contract; the face
resolution and selection live in face_selection.FaceEdgeSelector.
Source code in src/solidworks_mcp/adapters/solidworks/selection.py
select_feature
async
¶
Select a named feature, sketch, plane or component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_name
|
str
|
Feature name, optionally |
required |
append
|
bool
|
Add to the current selection instead of replacing it. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The selector payload plus |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
Source code in src/solidworks_mcp/adapters/solidworks/selection.py
Functions:¶
describe_edge ¶
Describe an IEdge in millimetres; unresolvable fields are omitted.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: |
dict[str, Any]
|
|
dict[str, Any]
|
(straight-line length - a curved edge is longer), and |
dict[str, Any]
|
|
Source code in src/solidworks_mcp/adapters/solidworks/face_selection.py
selection_count ¶
Number of entities currently selected in model, or None.
Source code in src/solidworks_mcp/adapters/solidworks/com_utils.py
strip_op_prefix ¶
Drop _handle_com_operation's generic "Error in <op>: " prefix.
Expected failures (not found, nothing to select, rebuild errors) then read as plain sentences for the LLM caller.
Source code in src/solidworks_mcp/adapters/solidworks/com_utils.py
validate_face_query ¶
validate_face_query(point: list[float] | None, side: str | None, plane: str | None, edge_type: str) -> str | None
Check a select_face_edges request; return an error message or None.