You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to implement following workflow in pymechanical as en embedded instance:
launch app embedded
exit app embedded
launch new app embedded
I need this workflow in a larger script in case an error occurs, such as the loss of a licence, and I need to set up a new connection automatically at a later time.
My poblem is, that I can't close the app completely and get allways an error, if I want to launch a new app.
Under Discussion I found the Topic: How to close app? #475 with following answer:
Hi @RGPATCHI@pmaroneh, I believe you can still call app.exit() for 23R2. If the version is < 241, we use ExtAPI.Application.Close(). Otherwise, we use ExtAPI.Application.Exit()
I tried all these commands, but the error message is always the same:
Exception: Cannot have more than one embedded mechanical instance!
I am using Visual Studio Code and for the execution of the code:
Run Python File in Dedicated Terminal
📝 Steps to reproduce
I have tested all 3 versions from the answer in the discussion:
Run 1
AnsysVersion:
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:242
Software build date: 06/03/2024 14:47:58
Run 2
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "m:\A13\2019\MESSDATEN\SLAB\Sim\Basic\B0004\Python\Test_App_Close.py", line 25, in <module>
app = mech.App(version=242)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JORZIG\AppData\Local\pip_envs\pip_JOJE_py3119_ansys\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 130, in __init__
raise Exception("Cannot have more than one embedded mechanical instance!")
Exception: Cannot have more than one embedded mechanical instance!
Run 1
AnsysVersion:
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:242
Software build date: 06/03/2024 14:47:58
Run 2
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "m:\A13\2019\MESSDATEN\SLAB\Sim\Basic\B0004\Python\Test_App_Close.py", line 25, in <module>
app = mech.App(version=242)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JORZIG\AppData\Local\pip_envs\pip_JOJE_py3119_ansys\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 130, in __init__
raise Exception("Cannot have more than one embedded mechanical instance!")
Exception: Cannot have more than one embedded mechanical instance!
Run 1
AnsysVersion:
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:242
Software build date: 06/03/2024 14:47:58
Run 2
CRITICAL - - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "m:\A13\2019\MESSDATEN\SLAB\Sim\Basic\B0004\Python\Test_App_Close.py", line 25, in <module>
app = mech.App(version=242)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JORZIG\AppData\Local\pip_envs\pip_JOJE_py3119_ansys\Lib\site-packages\ansys\mechanical\core\embedding\app.py", line 130, in __init__
raise Exception("Cannot have more than one embedded mechanical instance!")
Exception: Cannot have more than one embedded mechanical instance!
Hi @jorzig1990 , Thanks for opening the issue. PyMechanical embedding will not allow to create multiple app in same script.
but if you want to work in a new session then you can use app.new() which clear current session and create new session of Mechanical ( similar to File->New in Mechanical) . You can use like below. In this case you don't have to start another app or close the one that is created, instead use the one already created.
Is there a solution to reconnect or restart with the app, if I have lost the license connection or it crashed for some other reason?
Your solution works fine as long I don't have a problem with the app itself.
🔍 Before submitting the issue
🐞 Description of the bug
Hello,
I want to implement following workflow in pymechanical as en embedded instance:
launch app embedded
exit app embedded
launch new app embedded
I need this workflow in a larger script in case an error occurs, such as the loss of a licence, and I need to set up a new connection automatically at a later time.
My poblem is, that I can't close the app completely and get allways an error, if I want to launch a new app.
Under Discussion I found the Topic: How to close app? #475 with following answer:
I tried all these commands, but the error message is always the same:
I am using Visual Studio Code and for the execution of the code:
📝 Steps to reproduce
I have tested all 3 versions from the answer in the discussion:
Test ExtAPI.Application.Exit()
Output ExtAPI.Application.Exit():
Test app.exit()
Output app.exit():
Test ExtAPI.Application.Close():
Output ExtAPI.Application.Close()
💻 Which operating system are you using?
Windows
📀 Which ANSYS version are you using?
AnsysVersion:
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:242
Software build date: 06/03/2024 14:47:58
Python 3.11.9
Environment completely built with pip
🐍 Which Python version are you using?
3.11
📦 Installed packages
The text was updated successfully, but these errors were encountered: