Skip to main content

PyAnsys Python PyPI GH-CI Codecov MIT Black

Overview

PyMechanical brings Ansys Mechanical to Python. It enables your Python programs to use Mechanical within Python’s ecosystem. It includes the ability to:

  • Connect to a remote Mechanical session

  • Embed an instance of Mechanical directly as a Python object

Install the package

Install PyMechanical using pip with:

pip install ansys-mechanical-core

For more details, see PyMechanical - Install the package

Dependencies

You must have a licensed copy of Ansys Mechanical installed. When using an embedded instance, that installation must be runnable from the same computer as your Python program. When using a remote session, a connection to that session must be reachable from your Python program.

Getting started

PyMechanical uses the built-in scripting capabilities of Mechanical. For information on the scripting APIs available, see the Scripting in Mechanical Guide in the Ansys Help.

Configuring the Mechanical installation

On a Windows system, the environment variable AWP_ROOT<ver> is configured when Mechanical is installed, where <ver> is the Mechanical release number, such as 231 for release 2023 R1. PyMechanical automatically uses this environment variable (or variables if there are multiple installations of different versions) to locate the latest Mechanical installation. On a Linux system, you must configure the AWP_ROOT<ver> environment variable to point to the absolute path of a Mechanical installation.

Starting a remote session

To start a remote session of Mechanical on your computer from Python, use the launch_mechanical() method. This methods returns an object representing the connection to the session:

import ansys.mechanical.core as pymechanical

mechanical = pymechanical.launch_mechanical()

Running commands on the remote session

Given a connection to a remote session, you can send an IronPython script. This uses the built-in scripting capabilities of Mechanical. Here is an example:

result = mechanical.run_python_script("2+3")
result = mechanical.run_python_script("ExtAPI.DataModel.Project.ProjectDirectory")

Using an embedded instance of Mechanical as a Python object

PyMechanical also supports directly embedding an instance of Mechanical as a Python object. In this mode, there is no externally running instance of Mechanical. This feature is supported on Windows for version 2023 R1 and later, and it will be supported on Linux for version 2023 R2 and later. Here is an example:

import ansys.mechanical.core as pymechanical

app = pymechanical.App()
result = app.ExtAPI.DataModel.Project.ProjectDirectory

Testing and Development

If you would like to test or contribute to the development of PyMechanical, please visit PyMechanical - Contributing.

Release files for ansys-mechanical-core 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansys-mechanical-core 0.7.2
File Size Uploaded
ansys-mechanical-core-0.7.2.tar.gz 46.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ansys-mechanical-core 0.7.2
File Interpreter ABI Platform
ansys_mechanical_core-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 97.7 kB

Release files / ansys-mechanical-core-0.7.2.tar.gz

Download URL ansys-mechanical-core-0.7.2.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
66512e3f752aeeedddb28d561b32921f74ea8ca4c7ea2fc1d929fcc93d5512fc
BLAKE2b-256 checksum
How to use checksums
42762aa7ab6742f28cbca1fec026af3591944baed2a92c0eaf198a7fd4a249b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / ansys_mechanical_core-0.7.2-py3-none-any.whl

Download URL ansys_mechanical_core-0.7.2-py3-none-any.whl
Size 51.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cd8b65cc685cd5f97d8719a440ac7a93823621b8af7807f016b1f9cc6e0d1fc
BLAKE2b-256 checksum
How to use checksums
ac72add1aa015d7378de715a17a8a3456a7ec97cc16e5e5a2566eeedce409104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release history Release notifications | RSS feed

0.13.3

2 release files

0.13.0

2 release files

0.12.9

2 release files

0.12.8

2 release files

0.12.7

2 release files

0.12.6

2 release files

0.12.5

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.11.9

2 release files

0.11.8

2 release files

0.11.7

2 release files

0.11.6

2 release files

0.11.5

2 release files

0.11.3

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.9

2 release files

0.10.8

2 release files

0.10.7

2 release files

0.10.6

2 release files

0.10.5

2 release files

0.10.3

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.3

2 release files

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page