solidworks_mcp.tools.macro_recording¶
solidworks_mcp.tools.macro_recording ¶
Macro Recording and Playback tools for SolidWorks MCP Server.
Provides tools for recording, managing, and executing SolidWorks macros for automation and workflow optimization.
Classes¶
CompatInput ¶
Bases: BaseModel
Base schema allowing legacy/extra fields used by existing tests.
Attributes:
| Name | Type | Description |
|---|---|---|
model_config |
Any
|
The model config value. |
MacroAnalysisInput ¶
Bases: CompatInput
Input schema for macro analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
analysis_depth |
str
|
The analysis depth value. |
analysis_type |
str
|
The analysis type value. |
macro_file |
str | None
|
The macro file value. |
macro_path |
str | None
|
The macro path value. |
suggest_optimizations |
bool
|
The suggest optimizations value. |
MacroBatchInput ¶
Bases: CompatInput
Input schema for batch macro operations.
Attributes:
| Name | Type | Description |
|---|---|---|
execution_order |
str
|
The execution order value. |
file_pattern |
str | None
|
The file pattern value. |
macro_list |
list[str]
|
The macro list value. |
source_directory |
str | None
|
The source directory value. |
stop_on_error |
bool
|
The stop on error value. |
target_directory |
str | None
|
The target directory value. |
MacroPlaybackInput ¶
Bases: CompatInput
Input schema for macro playback.
Attributes:
| Name | Type | Description |
|---|---|---|
execution_mode |
str | None
|
The execution mode value. |
execution_parameters |
dict[str, Any] | None
|
The execution parameters value. |
log_execution |
bool
|
The log execution value. |
macro_file |
str | None
|
The macro file value. |
macro_path |
str | None
|
The macro path value. |
parameters |
dict[str, Any]
|
The parameters value. |
pause_between_runs |
float
|
The pause between runs value. |
pause_on_error |
bool
|
The pause on error value. |
repeat_count |
int
|
The repeat count value. |
target_file |
str | None
|
The target file value. |
MacroRecordingInput ¶
Bases: CompatInput
Input schema for macro recording operations.
Attributes:
| Name | Type | Description |
|---|---|---|
auto_cleanup |
bool
|
The auto cleanup value. |
auto_stop |
bool
|
The auto stop value. |
capture_keyboard |
bool
|
The capture keyboard value. |
capture_mouse |
bool
|
The capture mouse value. |
description |
str
|
The description value. |
macro_name |
str | None
|
The macro name value. |
output_file |
str
|
The output file value. |
recording_mode |
str
|
The recording mode value. |
recording_name |
str | None
|
The recording name value. |
recording_quality |
str
|
The recording quality value. |
timeout_seconds |
int
|
The timeout seconds value. |
SolidWorksAdapter ¶
Bases: ABC
Base adapter interface for SolidWorks integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object | None
|
Configuration values for the operation. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_metrics |
Any
|
The metrics value. |
config |
Any
|
The config value. |
config_dict |
Any
|
The config dict value. |
Initialize adapter with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object | None
|
Configuration values for the operation. Defaults to None. |
None
|
Source code in src/solidworks_mcp/adapters/base.py
Methods:¶
activate_document
async
¶
Make an already-open document the active one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title_or_path
|
str
|
Title, full path, or file name of an open document. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was activated, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_arc
async
¶
add_arc(center_x: float, center_y: float, start_x: float, start_y: float, end_x: float, end_y: float) -> AdapterResult[str]
Add an arc to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
start_x
|
float
|
The start x value. |
required |
start_y
|
float
|
The start y value. |
required |
end_x
|
float
|
The end x value. |
required |
end_y
|
float
|
The end y value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_centerline
async
¶
Add a centerline to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x1 value. |
required |
y1
|
float
|
The y1 value. |
required |
x2
|
float
|
The x2 value. |
required |
y2
|
float
|
The y2 value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_chamfer
async
¶
Add an equal-distance chamfer feature to selected edges.
Chamfers the selected edges of the current solid body by the given distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
float
|
Chamfer distance in millimeters. |
required |
edge_names
|
list[str]
|
List of edge names to chamfer. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterResult |
AdapterResult[Any]
|
Feature result or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_circle
abstractmethod
async
¶
Add a circle to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
radius
|
float
|
The radius value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_drawing_view
async
¶
Add a view of a model to the active drawing sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the model path, orientation, position in millimetres and optional view scale. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new view's details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_ellipse
async
¶
add_ellipse(center_x: float, center_y: float, major_axis: float, minor_axis: float) -> AdapterResult[str]
Add an ellipse to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
major_axis
|
float
|
The major axis value. |
required |
minor_axis
|
float
|
The minor axis value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_fillet
async
¶
Add a fillet feature to selected edges.
Rounds the selected edges of the current solid body with the given radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Fillet radius in millimeters. |
required |
edge_names
|
list[str]
|
List of edge names to fillet. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterResult |
AdapterResult[Any]
|
Feature result or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_line
abstractmethod
async
¶
Add a line to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x1 value. |
required |
y1
|
float
|
The y1 value. |
required |
x2
|
float
|
The x2 value. |
required |
y2
|
float
|
The y2 value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_mate
async
¶
add_mate(component_a: str, component_b: str, entity_a: str = 'Front Plane', entity_b: str = 'Front Plane', mate_type: str = 'coincident', alignment: str = 'aligned', distance: float = 0.0, angle: float = 0.0) -> AdapterResult[dict[str, Any]]
Mate two components together in the active assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_a
|
str
|
First component instance name. |
required |
component_b
|
str
|
Second component instance name. |
required |
entity_a
|
str
|
Named feature on the first component. Defaults to "Front Plane". |
'Front Plane'
|
entity_b
|
str
|
Named feature on the second component. Defaults to "Front Plane". |
'Front Plane'
|
mate_type
|
str
|
Mate type, e.g. |
'coincident'
|
alignment
|
str
|
|
'aligned'
|
distance
|
float
|
Distance in millimetres, for a distance mate. Defaults to 0.0. |
0.0
|
angle
|
float
|
Angle in degrees, for an angle mate. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Mate details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_note
async
¶
Place a text note on the active drawing sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the note text, its position in millimetres and an optional font size in points. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The note's details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_polygon
async
¶
Add a regular polygon to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
radius
|
float
|
The radius value. |
required |
sides
|
int
|
The sides value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_rectangle
abstractmethod
async
¶
Add a rectangle to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x1 value. |
required |
y1
|
float
|
The y1 value. |
required |
x2
|
float
|
The x2 value. |
required |
y2
|
float
|
The y2 value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_sketch_circle
async
¶
add_sketch_circle(center_x: float, center_y: float, radius: float, construction: bool = False) -> AdapterResult[str]
Alias for add_circle used by some tool flows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
radius
|
float
|
The radius value. |
required |
construction
|
bool
|
The construction value. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_sketch_constraint
async
¶
add_sketch_constraint(entity1: str, entity2: str | None, relation_type: str, entity3: str | None = None) -> AdapterResult[str]
Apply a geometric constraint between sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity1
|
str
|
The entity1 value. |
required |
entity2
|
str | None
|
The entity2 value. |
required |
relation_type
|
str
|
The relation type value. |
required |
entity3
|
str | None
|
Third entity ID — only used by the
|
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_sketch_dimension
async
¶
add_sketch_dimension(entity1: str, entity2: str | None, dimension_type: str, value: float) -> AdapterResult[str]
Add a sketch dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity1
|
str
|
The entity1 value. |
required |
entity2
|
str | None
|
The entity2 value. |
required |
dimension_type
|
str
|
The dimension type value. |
required |
value
|
float
|
The value value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_spline
async
¶
Add a spline through the provided points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list[dict[str, float]]
|
The points value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
auto_center_marks
async
¶
auto_center_marks(view_name: str, mark_holes: bool = True, mark_fillets: bool = False, mark_slots: bool = True) -> AdapterResult[dict[str, Any]]
Auto-insert centre marks on circular features in a drawing view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_name
|
str
|
Name of a view on the active drawing. |
required |
mark_holes
|
bool
|
Mark holes / bores. |
True
|
mark_fillets
|
bool
|
Mark fillets. |
False
|
mark_slots
|
bool
|
Mark slots. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The view and before/after centre-mark |
AdapterResult[dict[str, Any]]
|
counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
check_interference
async
¶
Check the active assembly for interfering components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Any
|
Optional settings; |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Interference details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
check_sketch_fully_defined
async
¶
Check whether a sketch is fully defined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sketch_name
|
str | None
|
Optional sketch name to inspect. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Definition status payload. |
Source code in src/solidworks_mcp/adapters/base.py
close_model
abstractmethod
async
¶
Close the current model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save
|
bool
|
The save value. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
connect
abstractmethod
async
¶
create_assembly
abstractmethod
async
¶
Create a new assembly document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_axis
async
¶
Create a reference axis along a principal direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
"x", "y" or "z" (case-insensitive, leading ± stripped). |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The plane pair used and feature counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_cut
async
¶
Create a cut feature from an existing sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sketch_name
|
str
|
The sketch name value. |
required |
depth
|
float
|
The depth value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_cut_extrude
async
¶
Create a cut-extrude feature from the active sketch.
Cuts material from the current solid body using the active sketch profile. Equivalent to SolidWorks Insert > Cut > Extrude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ExtrusionParameters
|
Depth and direction parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterResult |
AdapterResult[Any]
|
Feature result or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_drawing
abstractmethod
async
¶
Create a new drawing document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_drawing_view
async
¶
Place a view of a model on the active drawing sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the model path, orientation, position in millimetres and optional view scale. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new view's details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_extrusion
abstractmethod
async
¶
Create an extrusion feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ExtrusionParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_loft
abstractmethod
async
¶
Create a loft feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
LoftParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_part
abstractmethod
async
¶
Create a new part document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
units
|
str | None
|
The units value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_reference_plane
async
¶
create_reference_plane(reference: str, offset: float = 0.0, angle: float = 0.0, flip: bool = False) -> AdapterResult[dict[str, Any]]
Create a reference plane offset from, or angled to, an existing plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
Name of the reference plane or planar face. |
required |
offset
|
float
|
Offset distance in millimetres. Defaults to 0.0. |
0.0
|
angle
|
float
|
Angle in degrees. Defaults to 0.0. |
0.0
|
flip
|
bool
|
Reverse the offset or angle direction. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new plane's name and parameters, or error. |
Source code in src/solidworks_mcp/adapters/base.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
|
"along_curve" or "face_center". |
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 "along_curve", offset from the edge start in millimetres. |
None
|
percent
|
float | None
|
For "along_curve", position as 0-100 of the edge length. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The mode and feature counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_revolve
abstractmethod
async
¶
Create a revolve feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
RevolveParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_sketch
abstractmethod
async
¶
Create a new sketch on the specified plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plane
|
str
|
The plane value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_sweep
abstractmethod
async
¶
Create a sweep feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
SweepParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_technical_drawing
async
¶
Lay out the standard views of a model on the active sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the model path and the projection angle. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The view names created, or error. |
Source code in src/solidworks_mcp/adapters/base.py
delete_feature
async
¶
Delete a named feature or sketch from the active model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Feature or sketch name. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was deleted, or error. |
Source code in src/solidworks_mcp/adapters/base.py
disconnect
abstractmethod
async
¶
exit_sketch
abstractmethod
async
¶
Exit sketch editing mode.
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
export_file
abstractmethod
async
¶
Export the current model to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the target file. |
required |
format_type
|
str
|
The format type value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
export_image
abstractmethod
async
¶
Export a viewport screenshot (PNG/JPG) of the current model.
Payload keys: file_path (str): Absolute output path. width (int): Image width in pixels. height (int): Image height in pixels. view_orientation (str): One of "isometric", "front", "top", "right", "back", "bottom", "current".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict
|
The payload value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict]
|
AdapterResult[dict]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
get_dimension
abstractmethod
async
¶
Get the value of a dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[float]
|
AdapterResult[float]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
get_mass_properties
abstractmethod
async
¶
Get mass properties of the current model.
Returns:
| Type | Description |
|---|---|
AdapterResult[MassProperties]
|
AdapterResult[MassProperties]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
get_metrics ¶
Get adapter metrics.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
get_model_info
abstractmethod
async
¶
Get metadata for the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
health_check
abstractmethod
async
¶
Get adapter health status.
Returns:
| Name | Type | Description |
|---|---|---|
AdapterHealth |
AdapterHealth
|
The result produced by the operation. |
insert_component
async
¶
insert_component(file_path: str, x: float = 0.0, y: float = 0.0, z: float = 0.0) -> AdapterResult[dict[str, Any]]
Insert a part or sub-assembly into the active assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Absolute path to the |
required |
x
|
float
|
X position in millimetres. Defaults to 0.0. |
0.0
|
y
|
float
|
Y position in millimetres. Defaults to 0.0. |
0.0
|
z
|
float
|
Z position in millimetres. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Component name and counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
is_connected
abstractmethod
¶
Check if connected to SolidWorks.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if connected, otherwise False. |
list_components
async
¶
List the top-level components of the active assembly.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: Component instance names, or error. |
Source code in src/solidworks_mcp/adapters/base.py
list_configurations
abstractmethod
async
¶
List configuration names for the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: The result produced by the operation. |
list_drawing_views
async
¶
List the views on the active drawing.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: View names, or error. |
Source code in src/solidworks_mcp/adapters/base.py
list_features
abstractmethod
async
¶
list_features(include_suppressed: bool = False, max_assembly_depth: int = 2) -> AdapterResult[list[dict[str, Any]]]
List model features from the feature tree.
For a Part document, returns that document's own feature list,
unchanged from prior behavior. For an Assembly document, returns a
single flat list containing the assembly's own top-level features
plus every resolved component's features, recursing into
sub-assemblies up to max_assembly_depth. Every descriptor gains
component, component_path, and component_parent keys:
None for a document's own features (Part features, or an Assembly's
top-level features), or the owning component's name/path for a
component-derived feature. component_parent is the immediate parent
component name when the component is nested inside a sub-assembly,
otherwise None. A component that cannot be resolved (suppressed,
lightweight-and-unloaded, missing file) is represented by one descriptor
with type: "UnresolvedComponent" instead of being silently dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_suppressed
|
bool
|
The include suppressed value. Defaults to False. Applied independently to the assembly's own features and to each component's features. |
False
|
max_assembly_depth
|
int
|
How many levels of sub-assembly to recurse into. Defaults to 2. Ignored for Part documents. A component beyond the configured depth still appears in the result as a single descriptor (name + path), not expanded. |
2
|
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
list_open_documents
async
¶
Enumerate every document currently open in SolidWorks.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: One entry per open document |
AdapterResult[list[dict[str, Any]]]
|
( |
Source code in src/solidworks_mcp/adapters/base.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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[str]
|
Body or feature names to mirror. |
required |
mirror_plane
|
str
|
Plane name to mirror about. |
required |
merge
|
bool
|
Merge the mirrored result with the original. Defaults to True. |
True
|
mirror_bodies
|
bool
|
Mirror whole bodies rather than features. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The mirror feature's name, inputs and volume |
AdapterResult[dict[str, Any]]
|
before/after, or error. |
Source code in src/solidworks_mcp/adapters/base.py
open_model
abstractmethod
async
¶
Open a SolidWorks model (part, assembly, or drawing).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the target file. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[str]
|
Names of the features to pattern. |
required |
axis
|
str
|
Name of the axis to rotate about. |
required |
count
|
int
|
Total number of instances including the original. |
required |
angle
|
float
|
Total angle in degrees to spread them over. Defaults to 360.0. |
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, or error. |
Source code in src/solidworks_mcp/adapters/base.py
rename_feature
async
¶
Rename an existing feature on the feature tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_name
|
str
|
Current feature name. |
required |
new_name
|
str
|
New feature name. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The old and new names, or error. |
Source code in src/solidworks_mcp/adapters/base.py
save_body_as_part
async
¶
Extract one solid body from the active multibody part to a new file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_name
|
str
|
Name of a solid body in the active part. |
required |
file_path
|
str
|
Absolute path for the new |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The body, the written path, and the |
AdapterResult[dict[str, Any]]
|
solid-body names found, or error. |
Source code in src/solidworks_mcp/adapters/base.py
save_file
async
¶
Save the active model to the existing path or the provided path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | None
|
Path to the target file. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
set_dimension
abstractmethod
async
¶
Set the value of a dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
value
|
float
|
The value value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
set_units
async
¶
Set the active document's linear unit system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_system
|
str
|
One of |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was applied, or error. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_circular_pattern
async
¶
Create a circular pattern of sketch entities around the sketch origin.
The rotation axis is always the sketch origin — SW's
CreateCircularSketchStepAndRepeat has no pattern-centre
parameter and derives the axis from the seed's geometry. Place
the seed entity at the desired radius from the origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
angle
|
float
|
The angle value. |
required |
count
|
int
|
The count value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_linear_pattern
async
¶
sketch_linear_pattern(entities: list[str], direction_x: float, direction_y: float, spacing: float, count: int) -> AdapterResult[str]
Create a linear pattern of sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
direction_x
|
float
|
The direction x value. |
required |
direction_y
|
float
|
The direction y value. |
required |
spacing
|
float
|
The spacing value. |
required |
count
|
int
|
The count value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_mirror
async
¶
Mirror sketch entities about a mirror line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
mirror_line
|
str
|
The mirror line value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_offset
async
¶
sketch_offset(entities: list[str], offset_distance: float, reverse_direction: bool) -> AdapterResult[str]
Offset sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
offset_distance
|
float
|
The offset distance value. |
required |
reverse_direction
|
bool
|
The reverse direction value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
suppress_feature
async
¶
Suppress or unsuppress a named feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Feature name. |
required |
suppress
|
bool
|
True to suppress, False to unsuppress. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The resulting state, or error. |
Source code in src/solidworks_mcp/adapters/base.py
undo
async
¶
Undo the last operations in the active model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of steps to undo. |
1
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Whether the tree changed, or error. |
Source code in src/solidworks_mcp/adapters/base.py
update_metrics ¶
Update adapter metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_time
|
float
|
The operation time value. |
required |
success
|
bool
|
The success value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/base.py
Functions:¶
register_macro_recording_tools
async
¶
Register macro recording and playback tools with FastMCP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mcp
|
FastMCP
|
The mcp value. |
required |
adapter
|
SolidWorksAdapter
|
Adapter instance used for the operation. |
required |
config
|
Any
|
Configuration values for the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Example
tool_count = await register_macro_recording_tools(mcp, adapter, config)
Source code in src/solidworks_mcp/tools/macro_recording.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 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 309 310 311 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 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 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 | |