execute_code
Run Python code inside FreeCAD to build, modify, inspect, or automate 3D CAD models; optionally return screenshots from a chosen view.
Instructions
Execute arbitrary Python code in FreeCAD.
Args: code: The Python code to execute. include_screenshot: Whether to return a screenshot of the model (default True). Set to False to save tokens when the code does not change the model's appearance, e.g. analytical or computational scripts whose result is printed output, or intermediate steps in a longer sequence of changes. view_name: The view orientation of the returned screenshot (default "Isometric"). Pick the view that best shows the change being made. timeout: Positive finite seconds for each of the queue and GUI execution budgets, overriding the 90 s default for this call (capped at 1800). Raise it for slow work that must run on the GUI thread, such as importing or exporting a large STEP assembly. Without it the call reports a timeout while the task keeps running; poll get_task_status using the returned task_id for the late result. Prefer execute_code_async for heavy pure-geometry work that touches neither the document nor the GUI.
Returns: A message indicating the success or failure of the code execution, the output of the code execution, and a screenshot of the object.
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": {
"code": "<code>"
},
"name": "execute_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No | ||
| view_name | No | Isometric | |
| include_screenshot | No |