vw_exec_python
Runs arbitrary Python inside Vectorworks when no typed tool fits, with linting and validation before execution to catch bad vs.* calls.
Instructions
Run arbitrary Python inside Vectorworks; the last resort when no typed tool fits.
Prefer the typed vw_* tools (they verify and revert precisely); give
path for a script that already lives in a file, and use vw_lint to
check code without running it. The code is linted first, then every vs.*
call is checked inside Vectorworks (argument count and types, known
crashers): a bad call comes back as VSArgumentError / VSUnsafeError in
the result instead of opening the modal "Script Errors" window. Look up
signatures with vw_vs_lookup.
Changes the document when the code does. Objects the code creates are revertible with vw_revert_last; changes to objects that existed before (moves, attributes, deletions) are not, and such a call blocks stepping further back. Returns {ok, value, stdout, error, traceback, created, revertable, warning?, lint_warnings?}.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "vw_exec_python"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Python source to run inside Vectorworks with `vs` in scope (or give `path` instead). Python 3.9 syntax (Vectorworks 2026 embeds 3.9; no match statements, no `X | Y` types). Its stdout, the value of the last expression or of a variable named `result`, and any traceback are returned. Handles are only valid during the call: return UUIDs (vs.GetObjectUuid) to refer to objects later. | |
| lint | No | True (default): check the code before sending it (same as vw_lint). Syntax errors, vs.* calls with a wrong argument count, deprecated calls and functions known to crash Vectorworks or open a dialog stop the call with a report; unknown vs.* names come back as lint_warnings. False skips the check; only when the check itself is wrong. | |
| path | No | Instead of code: path of a Python script file on this Mac ("~" is expanded), for example in the project's _claude_scripts folder. Its contents run exactly like code; give one of code and path, not both. | |
| timeout | No | Seconds to wait for the result once Vectorworks has taken the job. Default 120; raise it for scripts that create many objects. | |
| document | No | Name of the document this must run in, as vw_list_documents shows it (".vwx" may be left out) or its full path. If another document is active, nothing changes. Omit to act on whatever document is active. | |
| allow_dialogs | No | False (default): vs.* functions that open a dialog are refused, because an open dialog blocks every further job until the user closes it. True: allow them on purpose. | |
| modifies_document | No | True (default): the objects the code creates are recorded so vw_revert_last can delete exactly those, even if the code fails halfway. False: run as read-only code (faster, no journal entry); use it for anything that only reads. |