PyMechanical Logo Light PyMechanical Logo Dark

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:

Embedding mode

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

Overview
Remote session mode

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

Overview

If you are not sure which mode to pick, see Choose your mode.


Getting started

Install PyMechanical, choose your mode, and run your first script.

Install Choose mode Quick start

Getting started
User guide

Learn how to use embedding mode, remote sessions, scripting, and CLI tools.

Embedding Remote Scripting

User guide
Examples

Explore examples, which are organized by mode and simulation type.

Embedding Remote Advanced

Examples
API reference

Understand PyMechanical API endpoints and their capabilities.

Classes Methods Error handling

API reference
FAQs

Frequently asked questions and their answers.

How Why What

FAQs
Known issues and limitations

See issues and limitations for both PyMechanical and Mechanical.

24R2 25R1 25R2 26R1

Known issues and limitations
Contribute

Learn how to contribute to the PyMechanical codebase or documentation.

Test Documentation Issues

Contribute