run_fem_analysis
Runs CalculiX FEA on an existing FreeCAD Fem::AnalysisPython container and returns max von Mises stress, displacements, node count, and solver working directory.
Instructions
Run the CalculiX solver on an existing Fem::FemAnalysis container and return summary results.
Prerequisites in the document, all created with create_object:
A Part-derived solid (e.g. Part::Box, PartDesign::Body) acting as the geometry.
A Fem::AnalysisPython container.
A material: type "Fem::MaterialCommon" with analysis_name set (built with ObjectsFem.makeMaterialSolid) and its Material given as a dict with units, e.g. {"Name": "Steel", "YoungsModulus": "210 GPa", "PoissonRatio": "0.3", "Density": "7900 kg/m^3"}. A dict read from the material library can come back empty; give the values.
A mesh: type "Fem::FemMeshGmsh" with analysis_name, Shape (the geometry) and CharacteristicLengthMax / CharacteristicLengthMin; it is generated when created. A section needs several elements across its thickness, or bending stress comes out far too low.
At least one Fem::ConstraintFixed and one Fem::ConstraintForce (or ConstraintPressure) whose References are faces of the geometry.
Set Force with its unit, e.g. "1000 N": create_object/edit_object reject unitless values. In existing documents and execute_code, a plain number uses millinewtons, so Force = 1000 applies 1 N. The force acts along the normal of the loaded face unless Direction links an edge or face; Reversed flips it.
A SolverCcxTools is auto-created if the analysis has none. The reply lists mechanical loads captured in the same GUI operation as the solve (in N and MPa, with faces and direction). A failed load read stops the solve. Direction can be set to {"object_name": "Beam", "edge": "Edge1"}.
The solver runs synchronously on the FreeCAD GUI thread. Other document operations queue behind it; get_rpc_status and get_async_status remain available.
Returns max von Mises stress (MPa), max/min displacement (mm), node count, and the working directory CalculiX wrote to. On failure, returns the prerequisite-check or solver error along with the working directory for triage.
Args: doc_name: Name of the FreeCAD document. analysis_name: Name of the Fem::AnalysisPython object. timeout: Seconds to wait for the solver (default 600). include_screenshot: Whether to return a screenshot of the model (default True). Set to False to save tokens when only the numeric results are needed. view_name: The view orientation of the returned screenshot (default "Isometric").
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": {
"doc_name": "<doc_name>",
"analysis_name": "<analysis_name>"
},
"name": "run_fem_analysis"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeout | No | ||
| doc_name | Yes | ||
| view_name | No | Isometric | |
| analysis_name | Yes | ||
| include_screenshot | No |