connect_to_or_start_server#

ansys.sound.core.server_helpers._connect_to_or_start_server.connect_to_or_start_server(port=None, ip=None, ansys_path=None, use_license_context=False, license_increment_name='avrxp_snd_level1')#

Connect to or start a DPF server with the DPF Sound plugin loaded.

Parameters:
portint, default: None

Port that the DPF server is listening to.

ipstr, default: None

IP address for the DPF server.

ansys_pathstr, default: None

Root path for the Ansys installation. For example, “C:/Program Files/ANSYS Inc/v242”. This parameter is ignored if either the port or IP address is set.

use_license_contextbool, default: False

Whether to check out the DPF Sound license increment before using PyAnsys Sound (see parameter license_increment_name). If set to True, the function returns a LicenseContextManager object (None otherwise) in addition to the server object.

This improves performance if you are doing multiple calls to DPF Sound operators, as it allows a single check out of the license increment, rather than requiring a check out for each operator call. The license is checked back in (that is, released) when the LicenseContextManager object is deleted.

This parameter can also be used to force check out before running a script when only few DPF Sound license increments are available.

license_increment_namestr, default: “avrxp_snd_level1”

Name of the license increment to check out. Only taken into account if use_license_context is True. The default value is “avrxp_snd_level1”, which corresponds to the license required by Ansys Sound Pro.

Returns:
InProcessServer | GrpcServer

Server object started or connected to.

LicenseContextManager

Licensing context object. Retains the licence increment until the object is deleted. None if use_license_context is set to False.

Return type:

tuple[InProcessServer | GrpcServer, LicenseContextManager]

Notes

If a port or IP address is passed in arguments, or if the environment variable ANSRV_DPF_SOUND_PORT is defined with a port number, this function attempts to connect to a remote server at the specified port and/or IP address. Otherwise, the function attempts to start a local server, located at the path passed in ansys_path if specified, or at the path specified in the environment variable ANSYS_DPF_PATH if it is defined. Finally, if none of these arguments and environment variables is defined, the function attempts to start a local server from the latest Ansys installation folder. Note that, in any case, arguments are prioritized over environment variables.

Examples

Start a local DPF server with DPF Sound plugin from the latest Ansys installation folder.

>>> from ansys.sound.core.server_helpers import connect_to_or_start_server
>>> server, lic_context = connect_to_or_start_server(
...     ansys_path="C:/Program Files/ANSYS Inc/v261",
... )

Connect to a remote DPF server with DPF Sound plugin, through a given communication port.

>>> from ansys.sound.core.server_helpers import connect_to_or_start_server
>>> server, lic_context = connect_to_or_start_server(port=6780)

See also

Initialize PyAnsys Sound and check out the license

Example demonstrating how to connect to or start a DPF server with the DPF Sound plugin.