The path.py
module#
Summary#
Return a dictionary of available Ansys unified installation versions with their base paths. |
|
Search for the Mechanical path in the standard installation location. |
|
Searches for Ansys MAPDL path within the standard install location |
|
Searches for Ansys LS-Dyna path within the standard install location |
|
Obsolete method, use find_mapdl. |
|
Change your default Ansys MAPDL path. |
|
Change your default Ansys LS-Dyna path. |
|
Change your default Mechanical path. |
|
Deprecated, use change_default_mapdl_path instead |
|
Find the Mechanical path or query user. |
|
Find Ansys LD-Dyna’s path or query user. |
|
Find Ansys MAPDL’s path or query user. |
|
Deprecated, use save_mapdl_path instead |
|
Clear the entry of the specified product in the configuration file |
|
Acquires Ansys MAPDL Path: |
|
Acquires Ansys LS-Dyna Path from a cached file or user input |
|
Deprecated, use get_mapdl_path instead |
|
Acquires Ansys Mechanical Path |
|
Extract the product version from a path. |
|
Return a tuple with the latest ansys installation version and its path |
Module detail#
- path.get_available_ansys_installations(supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Dict[int, str] #
Return a dictionary of available Ansys unified installation versions with their base paths.
Notes
On Windows, It uses the environment variable
AWP_ROOTXXX
.The student versions are returned at the end of the dict and with negative value for the version.
Examples
>>> from ansys.tools.path import get_available_ansys_installations >>> get_available_ansys_installations() {222: 'C:\Program Files\ANSYS Inc\v222', 212: 'C:\Program Files\ANSYS Inc\v212', -222: 'C:\Program Files\ANSYS Inc\ANSYS Student\v222'}
Return all installed Ansys paths in Linux.
>>> get_available_ansys_installations() {194: '/usr/ansys_inc/v194', 202: '/usr/ansys_inc/v202', 211: '/usr/ansys_inc/v211'}
- path.find_mechanical(version: float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']] #
Search for the Mechanical path in the standard installation location.
- Returns:
Examples
On Windows:
>>> from ansys.tools.path import find_mechanical >>> find_mechanical() ('C:/Program Files/ANSYS Inc/v231/aisol/bin/winx64/AnsysWBU.exe', 23.1)
On Linux:
>>> find_mechanical() ('/usr/ansys_inc/v231/aisol/.workbench', 23.1)
- path.find_mapdl(version: int | float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']] #
Searches for Ansys MAPDL path within the standard install location and returns the path of the latest version.
- Parameters:
- version
int
,float
,optional
Version of Ansys MAPDL to search for. If using
int
, it should follow the conventionXXY
, whereXX
is the major version, andY
is the minor. If usingfloat
, it should follow the conventionXX.Y
, whereXX
is the major version, andY
is the minor. IfNone
, use latest available version on the machine.
- version
- Returns:
Examples
Within Windows
>>> from ansys.tools.path import find_mapdl >>> find_mapdl() 'C:/Program Files/ANSYS Inc/v211/ANSYS/bin/winx64/ansys211.exe', 21.1
Within Linux
>>> find_mapdl() (/usr/ansys_inc/v211/ansys/bin/ansys211, 21.1)
- path.find_dyna(version: int | float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']] #
Searches for Ansys LS-Dyna path within the standard install location and returns the path of the latest version.
- Parameters:
- version
int
,float
,optional
Version of Ansys LS-Dyna to search for. If using
int
, it should follow the conventionXXY
, whereXX
is the major version, andY
is the minor. If usingfloat
, it should follow the conventionXX.Y
, whereXX
is the major version, andY
is the minor. IfNone
, use latest available version on the machine.
- version
- Returns:
Examples
Within Windows
>>> from ansys.tools.path import find_dyna >>> find_dyna() 'C:/Program Files/ANSYS Inc/v232/ANSYS/bin/winx64/LSDYNA232.exe', 23.2
Within Linux
>>> find_dyna() (/usr/ansys_inc/v232/ansys/bin/lsdyna232, 23.2)
- path.find_ansys(version: float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']] #
Obsolete method, use find_mapdl.
- path.change_default_mapdl_path(exe_loc: str) None #
Change your default Ansys MAPDL path.
- Parameters:
- exe_loc
str
Ansys MAPDL executable path. Must be a full path.
- exe_loc
Examples
Change default Ansys MAPDL location on Linux
>>> from ansys.tools.path import change_default_mapdl_path, get_mapdl_path >>> change_default_mapdl_path('/ansys_inc/v201/ansys/bin/ansys201') >>> get_mapdl_path() '/ansys_inc/v201/ansys/bin/ansys201'
Change default Ansys location on Windows
>>> mapdl_path = 'C:/Program Files/ANSYS Inc/v193/ansys/bin/winx64/ANSYS193.exe' >>> change_default_mapdl_path(mapdl_path)
- path.change_default_dyna_path(exe_loc: str) None #
Change your default Ansys LS-Dyna path.
- Parameters:
- exe_loc
str
path to LS-Dyna executable. Must be a full path. This need not contain the name of the executable, because the name of the LS-Dyna executable depends on the precision.
- exe_loc
Examples
Change default Ansys LS-Dyna location on Linux
>>> from ansys.tools.path import change_default_dyna_path, get_dyna_path >>> change_default_dyna_path('/ansys_inc/v232/ansys/bin/lsdyna232') >>> get_dyna_path() '/ansys_inc/v232/ansys/bin/lsdyna232'
Change default Ansys LS-Dyna location on Windows
>>> dyna_path = 'C:/Program Files/ANSYS Inc/v232/ansys/bin/winx64/LSDYNA232.exe' >>> change_default_dyna_path(dyna_path)
- path.change_default_mechanical_path(exe_loc: str) None #
Change your default Mechanical path.
- Parameters:
- exe_loc
str
Full path for the Mechanical executable file to use.
- exe_loc
Examples
On Windows:
>>> from ansys.tools.path import change_default_mechanical_path, get_mechanical_path >>> change_default_mechanical_path('C:/Program Files/ANSYS Inc/v231/aisol/bin/win64/AnsysWBU.exe') >>> get_mechanical_path() 'C:/Program Files/ANSYS Inc/v231/aisol/bin/win64/AnsysWBU.exe'
On Linux:
>>> from ansys.tools.path import change_default_mechanical_path, get_mechanical_path >>> change_default_mechanical_path('/ansys_inc/v231/aisol/.workbench') >>> get_mechanical_path() '/ansys_inc/v231/aisol/.workbench'
- path.change_default_ansys_path(exe_loc: str) None #
Deprecated, use change_default_mapdl_path instead
- path.save_mechanical_path(exe_loc: str | None = None, allow_prompt: bool = True) str #
Find the Mechanical path or query user.
- Parameters:
- exe_loc
str
,optional
Path for the Mechanical executable file (
AnsysWBU.exe
). The default isNone
, in which case an attempt is made to obtain the path from the following sources in this order:The default Mechanical paths (for example,
C:/Program Files/Ansys Inc/vXXX/aiso/bin/AnsysWBU.exe
)The configuration file
User input
If a path is supplied, this method performs some checks. If the checks are successful, it writes this path to the configuration file.
- exe_loc
- Returns:
str
Path for the Mechanical executable file.
Notes
The location of the configuration file
config.txt
can be found inansys.tools.path.SETTINGS_DIR
. For example:>>> from ansys.tools.path import SETTINGS_DIR >>> import os >>> print(os.path.join(SETTINGS_DIR, "config.txt")) C:/Users/[username]]/AppData/Local/Ansys/ansys_tools_path/config.txt
You can change the default for the
exe_loc
parameter either by modifying theconfig.txt
file or by running this code:>>> from ansys.tools.path import save_mechanical_path >>> save_mechanical_path("/new/path/to/executable")
- path.save_dyna_path(exe_loc: str | None = None, allow_prompt: bool = True) str #
Find Ansys LD-Dyna’s path or query user.
If no
exe_loc
argument is supplied, this function attempt to obtain the Ansys LS-Dyna executable from (and in order):The default ansys paths (i.e.
'C:/Program Files/Ansys Inc/vXXX/ansys/bin/winx64/LSDYNAXXX'
)The configuration file
User input
If
exe_loc
is supplied, this function does some checks. If successful, it will write thatexe_loc
into the config file.- Parameters:
- exe_loc
str
,optional
Path of the LS-Dyna executable (‘lsdynaXXX’), by default
None
.
- exe_loc
- Returns:
str
Path of the LS-Dyna executable.
Notes
The location of the configuration file
config.txt
can be found inansys.tools.path.SETTINGS_DIR
. For example:>>> from ansys.tools.path import SETTINGS_DIR >>> import os >>> print(os.path.join(SETTINGS_DIR, "config.txt")) C:/Users/[username]/AppData/Local/Ansys/ansys_tools_path/config.txt
Examples
You can change the default
exe_loc
either by modifying the mentionedconfig.txt
file or by executing:>>> from ansys.tools.path import save_dyna_path >>> save_dyna_path('/new/path/to/executable')
- path.save_mapdl_path(exe_loc: str | None = None, allow_prompt: bool = True) str #
Find Ansys MAPDL’s path or query user.
If no
exe_loc
argument is supplied, this function attempt to obtain the Ansys MAPDL executable from (and in order):The default ansys paths (i.e.
'C:/Program Files/Ansys Inc/vXXX/ansys/bin/winx64/ansysXXX'
)The configuration file
User input
If
exe_loc
is supplied, this function does some checks. If successful, it will write thatexe_loc
into the config file.- Parameters:
- exe_loc
str
,optional
Path of the MAPDL executable (‘ansysXXX’), by default
None
.
- exe_loc
- Returns:
str
Path of the MAPDL executable.
Notes
The location of the configuration file
config.txt
can be found inansys.tools.path.SETTINGS_DIR
. For example:>>> from ansys.tools.path import SETTINGS_DIR >>> import os >>> print(os.path.join(SETTINGS_DIR, "config.txt")) C:/Users/[username]/AppData/Local/Ansys/ansys_tools_path/config.txt
Examples
You can change the default
exe_loc
either by modifying the mentionedconfig.txt
file or by executing:>>> from ansys.tools.path import save_mapdl_path >>> save_mapdl_path('/new/path/to/executable')
- path.save_ansys_path(exe_loc: str | None = None, allow_prompt: bool = True) str #
Deprecated, use save_mapdl_path instead
- path.clear_configuration(product: PRODUCT_TYPE | Literal['all']) None #
Clear the entry of the specified product in the configuration file
- path.get_mapdl_path(allow_input: bool = True, version: float | None = None, find: bool = True) str | None #
Acquires Ansys MAPDL Path:
First, it looks in the configuration file, used by save_mapdl_path Then, it tries to find it based on conventions for where it usually is. Lastly, it takes user input
- Parameters:
- allow_inputbool,
optional
Allow user input to find Ansys MAPDL path. The default is
True
.- version
float
,optional
Version of Ansys MAPDL to search for. For example
version=22.2
. IfNone
, use latest.- find: bool, optional
Allow ansys-tools-path to search for Ansys Mechanical in typical installation locations
- allow_inputbool,
- path.get_dyna_path(allow_input: bool = True, version: float | None = None, find: bool = True) str | None #
Acquires Ansys LS-Dyna Path from a cached file or user input
First, it looks in the configuration file, used by save_dyna_path Then, it tries to find it based on conventions for where it usually is. Lastly, it takes user input
- Parameters:
- allow_inputbool,
optional
Allow user input to find Ansys LS-Dyna path. The default is
True
.- version
float
,optional
Version of Ansys LS-Dyna to search for. For example
version=22.2
. IfNone
, use latest.- find: bool, optional
Allow ansys-tools-path to search for Ansys Mechanical in typical installation locations
- allow_inputbool,
- path.get_ansys_path(allow_input: bool = True, version: float | None = None) str | None #
Deprecated, use get_mapdl_path instead
- path.get_mechanical_path(allow_input: bool = True, version: float | None = None, find: bool = True) str | None #
Acquires Ansys Mechanical Path
First, it looks in the configuration file, used by save_mechanical_path Then, it tries to find it based on conventions for where it usually is. Lastly, it takes user input
- Parameters:
- allow_inputbool,
optional
Allow user input to find Ansys Mechanical path. The default is
True
.- version
float
,optional
Version of Ansys Mechanical to search for. For example
version=22.2
. IfNone
, use latest.- find: bool, optional
Allow ansys-tools-path to search for Ansys Mechanical in typical installation locations
- allow_inputbool,
- path.version_from_path(product: PRODUCT_TYPE, path: str) int #
Extract the product version from a path.
- path.get_latest_ansys_installation() Tuple[int, str] #
Return a tuple with the latest ansys installation version and its path
If there is a student version and a regular installation for the latest release, the regular one is returned
- path.PLUGINS: Dict[str, ansys.tools.path.applications.ApplicationPlugin]#
- path.LOG#
- path.PRODUCT_TYPE#
- path.SUPPORTED_VERSIONS_TYPE#
- path.LINUX_DEFAULT_DIRS#
- path.CONFIG_FILE_NAME = 'config.txt'#
- path.SUPPORTED_ANSYS_VERSIONS: SUPPORTED_VERSIONS_TYPE#
- path.PRODUCT_EXE_INFO#
- path.SETTINGS_DIR#
- path.CONFIG_FILE#
- path.linux_default_dirs = [['/', 'usr', 'ansys_inc'], ['/', 'ansys_inc'], ['/', 'install', 'ansys_inc']]#