Skip to main content

ANSYS MAPDL interface using partial files from omniORB and omniORBpy

Project description

This python module provides minimum support for connecting to an ANSYS APDL server using Python. While it is designed to be used as a support module to support pyansys, it can be used individually to send text commands to an APDL instance, but with none of the syntax checking or error handling pyansys uses. In short, if you find yourself here, install pyansys unless you really want a quick and dirty solution to driving ANSYS APDL from Python.

This module relies on documentation provided by ANSYS APDL and uses compiled libraries using both source file from omniORB. See the shell files on the GitHub repository for Linux build instructions. Building for Windows was a nightmare.


Pre-compiled binary files are available for Python 2.7, 3.5, and 3.6 for Linux and Windows. Open an issue if you need another version. Python 3.7 is unavailable as the source isn’t compiling. Wait until 4.2.3 or greater is released. Contact the maintainer at omniORB.

Installation is simply:

pip install ansys_corba


Once again, you really should be using pyansys. It handles figuring out where the mapdl_broadcasts.txt file is and when to open a connection with the server. If you’d rather live on the wild side, here’s how you’d open ANSYS, connect to a CORBA server, and send over a few commands:

import sys
import time
import os
from ansys_corba import CORBA
import subprocess

# edit this to match your ansys exe
ansys_loc = 'C:\\Program Files\\ANSYS Inc\\v170\\ansys\\bin\winx64\\ANSYS170.exe'

# ansys apdl logging here:
logfile = 'mapdl_broadcasts.txt'
if os.path.isfile(logfile):

# make temporary input file to stop ansys from prompting the user
with open('tmp.inp', 'w') as f:

# start ANSYS
command = '"%s" -aas -i tmp.inp -o out.txt -b' % ansys_loc
subprocess.Popen(command, stdout=subprocess.PIPE)

# monitor log file and wait for connection
print('Starting ANSYS...')
while True:
        if os.path.isfile(logfile):
            with open(logfile, 'r') as f:
                text =
                if 'visited:collaborativecosolverunitior' in text:
                    print('ANSYS started')
    except KeyboardInterrupt:

with open('./aaS_MapdlId.txt') as f:
    key =

# create server
orb = CORBA.ORB_init()
mapdl = orb.string_to_object(key)

# run simple commands to demonstrate this works
out = mapdl.executeCommandToString('cylind, 2, , , 2, 0, 90')
print(out.replace('\\n', '\n'))
mapdl.terminate()  # could use exit, but it returns an error

There’s several things that could break here, for example, your path to ANSYS, or finding the mapdl_broadcasts.txt file. If this python script isn’t running in the same directory as ANSYS, it will hang until you kill the process or exit it with a keyboard interrupt.

Further Documentation

Once you’ve opened a connection to ANSYS, there’s really only three commands that you need to use. This documentation was shamelessly taken from sharcnet.

  • executeCommand:

    Issues a command to the connected Mechanical APDL session. Output from the command is not returned.

  • executeCommandToString

    Issues a command to the connected Mechanical APDL session and returns the output as a string.

  • terminate

    Terminates the connected Mechanical APDL as a Server session.

See the sharcnet documentation for more details


Installing from source is not possible using PyPi as the shared libraries need to be compiled outside of Python. I’ve included and which can be used to build the source code for Linux. Building for Windows is more complicated and requires following the readme within the omniorb source along with some trial and error.

License and Acknowledgments

This code is licensed under the MIT license.

This module, ansys_corba makes no commercial claim over ANSYS whatsoever. This tool extends the functionality of ANSYS by adding a python interface in both file interface as well as interactive scripting without changing the core behavior or license of the original software. The use of the interactive APDL control of ansys_corba requires a legally licensed local copy of ANSYS.

Also, this module wouldn’t be possible without omniORB as most of the source code is directly take from omniORBpy with only minor modifications to the file structure and the addition of documentation specific to ANSYS.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

ansys_corba-0.1.1-cp38-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

ansys_corba-0.1.1-cp38-cp38-manylinux2010_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

ansys_corba-0.1.1-cp37-cp37m-manylinux2010_x86_64.whl (5.7 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

ansys_corba-0.1.1-cp36-cp36m-manylinux2010_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

ansys_corba-0.1.1-cp35-cp35m-manylinux2010_x86_64.whl (5.6 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

ansys_corba-0.1.1-cp27-cp27mu-manylinux2010_x86_64.whl (5.5 MB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

ansys_corba-0.1.1-cp27-cp27m-manylinux2010_x86_64.whl (5.5 MB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page