3.2. Mechanical APDL as a Server CORBA Interfaces

The central element of the Mechanical APDL as a Server SDK is a CORBA interface you can use in building a client application. This interface is included in the standard installation of Mechanical APDL.

3.2.1. ICoMapdlUnit

The ICoMapdlUnit interface provides a set of functions that perform typical commands in Ansys Mechanical for solving a simulation.

Interface ICoMapdlUnit
string getComponentName();

Returns the name of the connected component.

void setComponentName(in string name);

Sets the name of the component to name.

string getComponentDescription();

Returns the description of the connected component.

void setComponentDescription(in string desc);

Sets the description of the connected component to desc.

void uploadFileFromBuffer(in string p_szFileName, in CoOctetBuffer p_pFileContent);

Writes a file named p_szFileName in the remote Mechanical APDL session working directory with the contents of p_pFileContent. If p_szFileName exists, it is overwritten.

CoOctetBuffer downloadFileFromBuffer(in string p_szFileName);

Returns the contents of the file name p_szFileName in the remote Mechanical APDL session working directory.

void executeCommand(in string p_stringCommand);

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

string executeCommandToString (in string p_stringCommand);

Issues a command to the connected Mechanical APDL session and returns the output as a string. Some commands are not supported. See details in section Unsupported Commands.

void terminate();

Terminates the connected Mechanical APDL as a Server session.

3.2.2. Exceptions

The following exceptions can be generated by a Mechanical APDL as a Server session, and should be appropriately handled by client applications:

exception EAnsysUnknown {
  long code; Code for the exception
  string description; Short description of the exception
  string scope; Area from where the exception has been thrown
  string interfaceName; Interface generating the exception (currently only ICoMapdlUnit)
  string operation; Method called
  string moreInfo; Additional information about the exception
}
exception EAnsysInvalidArgument {
  long code; Code for the exception
  string description; Short description of the exception
  string scope; Area from where the exception has been thrown
  string interfaceName; Interface generating the exception (currently only ICoMapdlUnit)
  string operation; Method called
  string moreInfo; Additional information about the exception
  short position; Position of the invalid argument
}

You can get more information from an exception by reading its description. In MATLAB, run the command in a try block, and then print the description of the exception.

try
    orb=initialize_orb();
    load_ansys_aas;
    iCoMapdlUnit=actmapdlserver(orb,'aaS_MapdlId.txt');
    iCoMapdlUnit.executeCommandToString('*IF,1,EQ,1,THEN')
catch ex
    disp(ex)
    ex.message
end
foo=ex.ExceptionObject;
foo.description

3.2.3. Using the CORBA Interface

In order to use the CORBA interface for your client application, you must build the interface modules for your development environment by compiling the supplied Interface Definition Language (IDL) file using a suitable IDL compiler.

In a standard installation, the Mechanical APDL as a Server IDL file is located in the directory C:\Program Files\ANSYS Inc\v242\ansys\customize\user.

Refer to the documentation for your CORBA implementation and development environment for details on how to compile the IDL file and including the resulting modules in your application.

3.2.4. Unsupported Commands

The following commands are not supported when running Mechanical APDL as a Server.