solidworks_mcp.adapters.solidworks.io¶
solidworks_mcp.adapters.solidworks.io ¶
Model I/O mixin for PyWin32 SolidWorks operations.
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)
Bases: Generic[T]
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. |
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. |
SolidWorksIOMixin ¶
Expose model open/save/create/configuration methods through a mixin.
Functions¶
close_model
async
¶
Close the current SolidWorks model and optionally save first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: Result of the close operation. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
create_assembly
async
¶
Create a new assembly document and set it as active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Reserved for future naming policy. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: Metadata for the new assembly document. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
create_drawing
async
¶
Create a new drawing document and set it as active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Reserved for future naming policy. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: Metadata for the new drawing document. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
create_part
async
¶
Create a new part document and set it as active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Reserved for future naming policy. |
None
|
units
|
str | None
|
Reserved for future units policy. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: Metadata for the new part document. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
get_dimension
async
¶
Read a named model dimension in millimetres.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Fully-qualified dimension name. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[float]
|
AdapterResult[float]: Dimension value in millimetres. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
get_mass_properties
async
¶
Get mass properties for the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[MassProperties]
|
AdapterResult[MassProperties]: Computed mass, volume, area, COM, and inertia. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
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 | |
get_model_info
async
¶
Collect summary metadata about the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Model information payload. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
list_configurations
async
¶
List all configuration names on the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: Configuration names, or empty list when unavailable. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
open_model
async
¶
Open a SolidWorks model file and set it as active on the adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to a |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: Model metadata for the opened document. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
rebuild_model
async
¶
Force a model rebuild.
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: Result of the rebuild operation. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
save_file
async
¶
Save the active model to its current path or to a new file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | None
|
Optional target path for Save As. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: Result of the save operation. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
set_dimension
async
¶
Set a named model dimension in millimetres and rebuild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Fully-qualified dimension name. |
required |
value
|
float
|
New value in millimetres. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: Result of the set operation. |
Source code in src/solidworks_mcp/adapters/solidworks/io.py
SolidWorksModel ¶
Bases: BaseModel
SolidWorks model information.
Attributes:
| Name | Type | Description |
|---|---|---|
configuration |
str | None
|
The configuration value. |
is_active |
bool
|
The is active value. |
name |
str
|
The name value. |
path |
str
|
The path value. |
properties |
dict[str, Any] | None
|
The properties value. |
type |
str
|
The type value. |