execute_code
Run Python code in FreeCAD to automate modeling, geometry analysis, imports/exports, and GUI tasks; get printed output and an optional screenshot for verification.
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, and the result is lost even though the work finishes. 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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No | ||
| view_name | No | Isometric | |
| include_screenshot | No |