execute_code
Execute Python code in FreeCAD to automate parametric modeling, assembly, and geometry sensing. Capture output and optional screenshots for verification.
Instructions
Execute arbitrary Python code in FreeCAD.
The code runs on FreeCAD's GUI thread with the full FreeCAD Python API
available (FreeCAD, FreeCADGui already imported; import Part/Draft/etc.
as needed). print() output is captured and returned.
Args:
code: The Python code to execute.
with_screenshot: Attach a screenshot after successful execution
(default: no screenshot).
Returns:
A message indicating the success or failure of the code execution, the
output of the code execution, and a screenshot only when requested.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| with_screenshot | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |