connect_to_instance#
- ansys.mapdl.core.cli.helpers.connect_to_instance(ip=None, port=None, clear_on_connect=False, timeout=10)#
Connect to an already running MAPDL instance.
- Parameters:
- ip
str,optional IP address of the MAPDL gRPC server. When
None, the value of thePYMAPDL_IPenvironment variable is used, defaulting to"127.0.0.1".- port
int,optional Port of the MAPDL gRPC server. When
None, the value of thePYMAPDL_PORTenvironment variable is used, defaulting to50052.- clear_on_connectbool, default:
False Whether to clear the MAPDL database upon connecting.
- timeout
int, default: 10 Seconds to wait when establishing the gRPC connection.
- ip
- Returns:
ansys.mapdl.core.mapdl_grpc.MapdlGrpcClient connected to the running instance.
- Raises:
MapdlConnectionErrorWhen no MAPDL instance can be reached at the given address. The underlying error is attached as a note on the exception, and the original traceback is suppressed to keep the failure readable.
- Return type:
Examples
Connect to the instance running on the default port:
>>> from ansys.mapdl.core.cli.helpers import connect_to_instance >>> mapdl = connect_to_instance()