PyMechanical Embedded SEH Exception during _start_application
Hi All, Could you help met with a question regarding the PyMechanical Embedded Application?
I'm trying to start a PyMechanical Embedded application but during the initialisation of the app it crashes and reports an SEH Exception. Using the Remote Connection for this process works without issues, however we would like to see if it is also possible to run this in an embedded process to integrate it with some of our other automation systems.
Steps To Repreduce
Run the following code in Spyder IDE
import logging import ansys.mechanical.core as mech from ansys.mechanical.core.embedding.logger import Configuration, Logger # app = mech.App(version = 241) from ansys.tools.path import find_mechanical Configuration.configure( level=logging.DEBUG, # Set the desired logging level directory="C:\\Users\\k.vanderraad\\Desktop\\log_files", # Directory to save the log files to_stdout=True # Output logs to standard output ) find_mechanical(version = 241) #This steps is successfull embedded = mech.App(version = 241, db_file="C:\\Users\\k.XXXXX\\Desktop\\export_mechanical.mechdat") ![](https://us.v-cdn.net/6037473/uploads/editor/9b/j9pjkkvk6e9z.png "")
Result
The system runs into an SEH exception with the following log and output
%runfile C:/Users/k.XXXXX/Desktop/ProTube_Python_Testing_Env2/starting_embedded.py --wdir 2024-09-17 15:14:32.874315 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : Checking debug stop 2024-09-17 15:14:32.874315 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : Setting environment 2024-09-17 15:14:32.875414 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : using aisolPath C:\Program Files\ANSYS Inc\v241\aisol\bin\winx64 2024-09-17 15:14:32.893249 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : running wb config 2024-09-17 15:14:32.895278 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : running AnsCoInitialize 2024-09-17 15:14:33.005950 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : ran AnsCoInitialize, result: 1 2024-09-17 15:14:33.006954 (Thread 0x000018a0) [EmbeddedMechanical, trace] ----- : ran AnsSetRegistryLoadConfiguration, result: 0 2024-09-17 15:14:33.013821 (Thread 0x000018a0) [WORKBENCH, info] --------------- : ************ Workbench 1 - version: 241 build: 20231127 ************ 2024-09-17 15:14:33.014902 (Thread 0x000018a0) [WORKBENCH, info] ----- ScopeBegin: CWB::FinalConstruct 2024-09-17 15:14:33.016005 (Thread 0x000018a0) [WORKBENCH, trace] -------------- : ActiveWBMgrObject creation succeeded 2024-09-17 15:14:33.016005 (Thread 0x000018a0) [WORKBENCH, trace] -------------- : WBCommandLine creation succeeded 2024-09-17 15:14:33.016005 (Thread 0x000018a0) [WORKBENCH, trace] -------------- : WBSplashScreen creation succeeded 2024-09-17 15:14:33.022848 (Thread 0x000018a0) [WORKBENCH, info] ----- ScopeEnd : CWB::FinalConstruct <8 ms> Traceback (most recent call last): File ~\Desktop\XXXX_Python_Testing_Env2\.env\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals exec_fun(compile(code_ast, filename, "exec"), globals) File c:\users\k.XXXXX\desktop\XXXX_python_testing_env2\starting_embedded.py:19 embedded = mech.App(version = 241, db_file="C:\\Users\\k.XXXXX\\Desktop\\export_mechanical.mechdat") File ~\Desktop\XXXX_Python_Testing_Env2\.env\Lib\site-packages\ansys\mechanical\core\embedding\app.py:141 in __init__ self._app = _start_application(configuration, self._version, db_file) File ~\Desktop\XXXX_Python_Testing_Env2\.env\Lib\site-packages\ansys\mechanical\core\embedding\app.py:78 in _start_application return Ansys.Mechanical.Embedding.Application(db_file, addin_configuration_name) SEHException: (0x80004005): Eine externe Komponente hat eine Ausnahme ausgelöst.![](https://us.v-cdn.net/6037473/uploads/editor/7j/hy9l9gyaer9s.png "")
Note: "Eine externe Komponente hat eine Ausnahme ausgelöst." translates to "An external component has raised an exception"
The person who takes care of the licence server also mentioned there were some issues around the time I was testing this. But we're not sure about the exact timing and whether or not this was a causal relation. We have just switched to a new server as well.
Expected Result
The Expected Result is that mech.App(version = 241, db_file="C:\Users\k.XXXXX\Desktop\export_mechanical.mechdat") returns an application object in which can be used as an embedded version of Ansys Mechanical.
What I've tried so far
*Prior to the run I'm always restarting the Kernel (because I get weird errors otherwise which I assume are caused by the improper shutdown resulting from the error above.
*Running the mech.App() without supplying a export_mechanical.mechdat
*Tried specifiefing the Ansys version in different ways
*In the Debugger checked if the specified version matched the initialised version
*In the Debugger checked whether _start_application was supplied all relevant info.
*Connected to remote session which worked as expected
*Verified that llicences were available (all though I'm not sure whether the embedded application can properly connect to them.
*Tommorrow I will also have a look with the colleague who manages the licence servers, however he does not have experience with PyAnsys so it would be great to have an idea of what we could look at during this session.
System
Operating System: Windows 11 via remote Desktop (running as a VM on a linux server)
Ansys Version: 2024R1
Licenses Available Via Licence Server
License Types: Floating, and Elastic (I can list the exact names of the licences on request)
Python Version: 3.11
IDE: Spyder 6.0.0 (pip)
Relevant Modules:
- ansys-api-mechanical==0.1.2
- ansys-api-platform-instancemanagement==1.1.0
- ansys-api-workbench==0.2.0
- ansys-mechanical-core==0.11.7
- ansys-mechanical-env==0.1.7
- ansys-platform-instancemanagement==1.1.2
- ansys-pythonnet==3.1.0rc3
- ansys-tools-path==0.6.0
- ansys-workbench-core==0.6.0
Please share your thoughts if you had similar issues, know the solution, or have ideas for next steps towards troubleshooting!
Thanks in advance for your time!
PS: First time posting here, any feedback is welcome!
Answers
-
Hi,
As the issue seems to be related to launching PyMechanical (and not on how to use some specific commands), I would encourage you to open an issue in Github: https://github.com/ansys/pymechanical/issues My colleagues from the PyMechanical development team will be better suited to help you in this case.
You're still very welcome to use the forum for any question on specific commands or scripts :-)0 -
Thanks for your feedback!
I've made the following post on github: https://github.com/ansys/pymechanical/issues/9181