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.
The following topics describe the CORBA interface and its use:
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 stringname); Sets the name of the component to
.name- string
getComponentDescription(); Returns the description of the connected component.
- void
setComponentDescription(in stringdesc); Sets the description of the connected component to
.desc- void
uploadFileFromBuffer(in stringp_szFileName, in CoOctetBufferp_pFileContent); Writes a file named
in the remote Mechanical APDL session working directory with the contents ofp_szFileName. Ifp_pFileContentexists, it is overwritten.p_szFileName- CoOctetBuffer
downloadFileFromBuffer(in stringp_szFileName); Returns the contents of the file name
in the remote Mechanical APDL session working directory.p_szFileName- void
executeCommand(in stringp_stringCommand); Issues a command to the connected Mechanical APDL session. Output from the command is not returned.
- string
executeCommandToString (in stringp_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.
- string
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
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.