Package: ansys-corba
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 supportpyansys, it can be used individually to send text commands to an APDL instance, but with none of the syntax checking or error handlingpyansysuses.  In short, if you find yourself here, installpyansysunless 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 fromomniORB.  See the shell files on the GitHubrepositoryfor Linux build instructions.  Building for Windows was a nightmare.InstallationPre-compiled binary files are available for Python 2.7, 3.5, and 3.6 for Linux and Windows.  Open anissueif 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 atomniORB.Installation is simply:pip install ansys_corbaUsageOnce again, you really should be usingpyansys.  It handles figuring out where themapdl_broadcasts.txtfile 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:importsysimporttimeimportosfromansys_corbaimportCORBAimportsubprocess# edit this to match your ansys exeansys_loc='C:\\Program Files\\ANSYS Inc\\v170\\ansys\\bin\winx64\\ANSYS170.exe'# ansys apdl logging here:logfile='mapdl_broadcasts.txt'ifos.path.isfile(logfile):os.remove(logfile)# make temporary input file to stop ansys from prompting the userwithopen('tmp.inp','w')asf:f.write('FINISH')# start ANSYScommand='"%s" -aas -i tmp.inp -o out.txt -b'%ansys_locsubprocess.Popen(command,stdout=subprocess.PIPE)# monitor log file and wait for connectionprint('Starting ANSYS...')whileTrue:try:ifos.path.isfile(logfile):withopen(logfile,'r')asf:text=f.read()if'visited:collaborativecosolverunitior'intext:print('ANSYS started')breaktime.sleep(0.1)exceptKeyboardInterrupt:sys.exit()withopen('./aaS_MapdlId.txt')asf:key=f.read()# create serverorb=CORBA.ORB_init()mapdl=orb.string_to_object(key)# run simple commands to demonstrate this worksmapdl.executeCommand('/prep7')out=mapdl.executeCommandToString('cylind, 2, , , 2, 0, 90')print(out.replace('\\n','\n'))mapdl.executeCommand('FINISH')mapdl.terminate()# could use exit, but it returns an errorThere’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 DocumentationOnce you’ve opened a connection to ANSYS, there’s really only three commands that you need to use.  This documentation was shamelessly taken fromsharcnet.executeCommand:Issues a command to the connected Mechanical APDL session. Output from the command is not returned.executeCommandToStringIssues a command to the connected Mechanical APDL session and returns the output as a string.terminateTerminates the connected Mechanical APDL as a Server session.See thesharcnetdocumentation for more detailsNotesInstalling from source is not possible using PyPi as the shared libraries need to be compiled outside of Python.  I’ve includeddocker_buildlinux.shanddocker.shwhich 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 AcknowledgmentsThis code is licensed under the MIT license.This module,ansys_corbamakes 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 ofansys_corbarequires a legally licensed local copy of ANSYS.Also, this module wouldn’t be possible withoutomniORBas 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.