solidworks_mcp.adapters.vba_macro_executor¶
solidworks_mcp.adapters.vba_macro_executor ¶
VBA macro execution lifecycle management for SolidWorks automation.
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. |
MacroExecutionRequest
dataclass
¶
Request to execute a VBA macro.
Attributes:
| Name | Type | Description |
|---|---|---|
macro_code |
str
|
The macro code value. |
macro_name |
str
|
The macro name value. |
subroutine |
str
|
The subroutine value. |
MacroExecutionResult
dataclass
¶
MacroExecutionResult(success: bool, macro_name: str, output: str | dict[str, Any] | None = None, error: str | None = None, duration_seconds: float = 0.0)
Result of VBA macro execution.
Attributes:
| Name | Type | Description |
|---|---|---|
duration_seconds |
float
|
The duration seconds value. |
error |
str | None
|
The error value. |
macro_name |
str
|
The macro name value. |
output |
str | dict[str, Any] | None
|
The output value. |
success |
bool
|
The success value. |
VbaMacroExecutor ¶
Manage VBA macro execution with save and tracking.
This executor handles the full lifecycle: code generation, on-disk persistence, execution via the backing adapter, and result tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_macro_dir
|
Path | None
|
The temp macro dir value. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_temp_macro_dir |
Any
|
The temp macro dir value. |
Initialize macro executor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temp_macro_dir
|
Path | None
|
The temp macro dir value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/vba_macro_executor.py
Functions¶
execute_macro
async
¶
execute_macro(request: MacroExecutionRequest, backing_adapter: Any) -> AdapterResult[MacroExecutionResult]
Provide execute macro support for the vba macro executor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
MacroExecutionRequest
|
The request value. |
required |
backing_adapter
|
Any
|
The backing adapter value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[MacroExecutionResult]
|
AdapterResult[MacroExecutionResult]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_macro_executor.py
get_execution_history ¶
Retrieve macro execution history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
macro_name
|
str | None
|
The macro name value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, MacroExecutionResult]
|
dict[ str, MacroExecutionResult, |
dict[str, MacroExecutionResult]
|
]: A dictionary containing the resulting values. |