Run Macro
execute_macroRun SolidWorks .swp/.swb macros or VBA source in the active SolidWorks session, calling a procedure to automate modeling tasks with optional repeat runs and dialog timeouts.
Instructions
Run a SolidWorks macro (.swp, or legacy .swb), or VBA source text, in the running SolidWorks, calling its main procedure.
Use it for a macro file, or VBA you wrote as vba_source. Source runs only
if the user set SOLIDWORKS_MCP_ALLOW_VBA_SOURCE to restricted or full, else
vba_source_off: ask the user, never set it yourself. Restricted source may
call SolidWorks on the open documents only, else vba_source_refused,
naming each line. The reply gives source_file and the vba_source run.
The macro must not wait for the user: a dialog still open after
dialog_timeout s (30) is answered with Cancel or its only button, and the
run fails as macro_waited_for_user; a Yes/No prompt is left. It runs
repeat_count times, pause_between_runs s apart, stopping at the first
failure. Needs: SolidWorks running. Changes: whatever the macro does; it
can't be undone from here. Returns: runs_completed and data from the
last run (macro_path, module_name, proc_name, errors).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"input_data": "<input_data>"
},
"name": "execute_macro"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data | Yes | The macro to run. Give `macro_path` (or `macro_file`), or `vba_source`; `proc_name` (main), `repeat_count` (1), `pause_between_runs` (0 s) and `dialog_timeout` (30 s) have defaults. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||