Run Python Script
run_scriptExecute Python in FreeCAD with App/Part/ObjectsFem in scope to create custom geometry or operations and return JSON results plus handles for new objects.
Instructions
Escape hatch: execute Python in the worker with App/Part/ObjectsFem in scope.
Set __result__ in the script to return a JSON-serializable value.
auto_register (default True): any new shape-bearing object the script
creates is automatically registered into the handle table. The result
includes a registered list of {handle, name, type} entries so the next
tool call (render_view, list_faces, fillet_edges, mass_properties, etc.)
can address script-created objects via handle without a separate
register_handle round-trip.
Disabled unless ANKUSDRIVE_ALLOW_RUN_SCRIPT permits it (the Claude Desktop extension defaults it off); when disabled this tool is not registered at all.
Returns {result, registered}.
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": "run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| workspace | No | Run this call in this named workspace | |
| auto_register | No |