Python API to interact with Ansys Mechanical (FEA software for structural engineering) in 2024 R2 and later.
PyMechanical provides two distinct modes of interacting with Mechanical. Choose the one that fits your workflow:
Run Mechanical directly in your Python process with the App class.
Provides full object-model access, fast startup, and is ideal for Jupyter notebooks
and interactive scripting.
from ansys.mechanical.core import App
app = App(globals=globals()) #always batch mode
print(app)
Model.AddStaticStructuralAnalysis()
In-process Direct API fast
Launch Mechanical as a separate server process and communicate with gRPC. Provides process isolation, and optional GUI, and is ideal for CI/CD, Docker and automation.
from ansys.mechanical.core import launch_mechanical
app = launch_mechanical() # either batch or GUI mode
print(app)
app.run_python_script("Model.AddStaticStructuralAnalysis()")
gRPC GUI Remote
If you are not sure which mode to pick, see Choose your mode.
Install PyMechanical, choose your mode, and run your first script.
Install Choose mode Quick start
Learn how to use embedding mode, remote sessions, scripting, and CLI tools.
Embedding Remote Scripting
Explore examples, which are organized by mode and simulation type.
Embedding Remote Advanced
Understand PyMechanical API endpoints and their capabilities.
Classes Methods Error handling
Frequently asked questions and their answers.
How Why What
See issues and limitations for both PyMechanical and Mechanical.
24R2 25R1 25R2 26R1
Learn how to contribute to the PyMechanical codebase or documentation.
Test Documentation Issues