execute_code
Execute custom Python code in FreeCAD to handle operations beyond standard tools. The code is checked for safety before running, and you receive output plus a screenshot.
Instructions
Execute arbitrary Python code in FreeCAD.
This is an unverified escape hatch: prefer the typed tools (pad, pocket,
place, measure, probe_material_at, fillet, chamfer, linear_pattern,
polar_pattern, create_sketch/add_rectangle/add_circle/add_polygon,
instantiate_family) for normal geometry work, since they check what
actually happened (volume, isValid, bounding box) instead of only
reporting whether the code raised — the usual CAD failure mode is an
operation that silently does nothing, not one that throws. Code
containing process-level imports (os/subprocess), eval/exec/open/
__import__, or Sketcher calls known to hang FreeCAD's solver (.solve(),
deleteAllGeometry(), movePoint() on an already-constrained sketch) is
rejected before it runs.
Args:
code: The Python code to execute.
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 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |