ansys / ansys/pyprimemesh

CAD import failed - ImportError: DLL load failed while importing PyFM

Open
#929 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
35
Forks
14
Avg merge
3d 5h
Merged PRs (30d)
11

Description

### 🔍 Before submitting the issue

- [x] I have searched among the existing issues
- [x] I am using a Python virtual environment

### 🐞 Description of the bug

Hello!
I'm having difficulties trying to run the block model example. It seems i'm unable to load the CAD with mesh_util read.

https://prime.docs.pyansys.com/version/stable/examples/gallery_examples/gallery/00_lucid_file_IO.html#sphx-glr-examples-gallery-examples-gallery-00-lucid-file-io-py

I'm currently using py3.11.9 in a virtual environment, with ansys 2024R2 and py prime mesh 0.6.2. I'm on windows10.0.19045 pro.
I used the ProductConfig.exe script in the ansys files to configure CAD readers, and i can successfully read the example in SpaceClaim.

I tried investigating, and i launched the prime server without the launch_prime() function (using a cmd, calling the runPrime.bat) and i noticed the server correctly booting, but as soon as i run the example script on Python, trying to connect to the server and read the geometry; the server crashes saying "the DLL load failed while importing PyFM: the OS cannot execute %1". As soon as this error arises on the server prompt, i get the import CAD failed error in my python script.
I also encountered the same problem with some of my coworkers.
Do you have, by any chance, any idea where this could be coming from? Thank you very much

### 📝 Steps to reproduce

1) First in a cmd prompt: "%AWP_ROOT242%\meshing\Prime\runPrime.bat" server

which shows:
C:\Users\Guillaume>"%AWP_ROOT242%\meshing\Prime\runPrime.bat" server
Welcome to Ansys Prime Meshing (2024R2)
Copyright 1987 - 2024 ANSYS,Inc. All Rights Reserved.
Starting Ansys Prime Server...
Server listening on : 127.0.0.1:50055

2) then i try running with python:
import ansys.meshing.prime as prime

prime_client = prime.Client(ip="127.0.0.1", port=50055)
model = prime_client.model
mesh_util = prime.lucid.Mesh(model=model)

mesh_util.read(file_name="D:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\pyprime_block_import.scdoc")

print(model)

3) On the cmd prompt i used to launch the prime server, the error arises:
C:\Users\Guillaume>"%AWP_ROOT242%\meshing\Prime\runPrime.bat" server
Welcome to Ansys Prime Meshing (2024R2)
Copyright 1987 - 2024 ANSYS,Inc. All Rights Reserved.
Starting Ansys Prime Server...
Server listening on : 127.0.0.1:50055
Traceback (most recent call last):
File "C:\Users\GUILLA~1\AppData\Local\Temp\pyprime1730384592775038_cad_import_script.py", line 5, in
from ansys.FM import FM
File "D:\ANSYS Inc\v242\meshing\Prime\ansys\FM\FM.py", line 54, in
import PyFM
ImportError: DLL load failed while importing PyFM: Le système d’exploitation ne peut pas exécuter %1.
(which is french for "the OS cannot execute %1)

![Image](https://github.com/user-attachments/assets/617f6eb9-04f9-4aee-8417-e4576ead5ebc)

4) The python scripts immediately crashes afterwards, with this error:
Traceback (most recent call last):
File "d:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\test.py", line 8, in
mesh_util.read(file_name=r"D:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\pyprime_block_import.scdoc")
File "D:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\virtualenviro\Lib\site-packages\ansys\meshing\prime\lucid\mesh_util.py", line 114, in read
prime.FileIO(self._model).import_cad(
File "D:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\virtualenviro\Lib\site-packages\ansys\meshing\prime\core\fileio.py", line 586, in import_cad
import_result = super().import_cad(temp_file_name, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\virtualenviro\Lib\site-packages\ansys\meshing\prime\autogen\fileio.py", line 692, in import_cad
result = self._comm.serve(self._model, command_name, self._object_id, args=args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\MEC8370\PyPrimeMesh\test PyPrimeMesh 3\virtualenviro\Lib\site-packages\ansys\meshing\prime\internals\error_handling.py", line 577, in wrapper_error_code
raise PrimeRuntimeError(
ansys.meshing.prime.internals.error_handling.PrimeRuntimeError: CAD import failed.

![Image](https://github.com/user-attachments/assets/8068d0a9-1ed4-4f5d-836b-c21f108be24c)

### 💻 Which operating system are you using?

Windows

### 📀 Which ANSYS version are you using?

2024R2

### 🐍 Which Python version are you using?

3.11

### 📦 Installed packages

ansys-meshing-prime==0.6.2

about-time==4.2.1
alive-progress==3.2.0
ansys-api-fluent==0.3.28
ansys-api-platform-instancemanagement==1.1.0
ansys-api-tools-filetransfer==0.1.0
ansys-fluent-core==0.26.1
ansys-fluent-visualization==0.14.0
ansys-platform-instancemanagement==1.1.2
ansys-tools-filetransfer==0.1.0
ansys-units==0.3.2
beartype==0.19.0
certifi==2024.8.30
charset-normalizer==3.4.0
click==8.1.7
colorama==0.4.6
contourpy==1.3.0
cycler==0.12.1
docker==7.1.0
fonttools==4.54.1
grapheme==0.6.0
grpcio==1.67.0
grpcio-health-checking==1.62.3
idna==3.10
importlib_metadata==8.5.0
joblib==1.4.2
kiwisolver==1.4.7
lxml==5.3.0
matplotlib==3.9.2
nltk==3.9.1
numpy==1.26.4
packaging==24.1
pandas==2.2.3
pillow==11.0.0
platformdirs==4.3.6
pooch==1.8.2
protobuf==4.25.5
psutil==6.1.0
pyparsing==3.2.0
PySide6==6.7.3
PySide6_Addons==6.7.3
PySide6_Essentials==6.7.3
python-dateutil==2.9.0.post0
pytz==2024.2
pyvista==0.44.1
pyvistaqt==0.11.1
pywin32==308
PyYAML==6.0.2
QtPy==2.4.1
regex==2024.9.11
requests==2.32.3
scipy==1.14.1
scooby==0.10.0
shiboken6==6.7.3
six==1.16.0
tqdm==4.66.6
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
vtk==9.3.1
zipp==3.20.2
about-time==4.2.1
alive-progress==3.2.0
ansys-api-fluent==0.3.28
ansys-api-meshing-prime==0.1.3
ansys-api-platform-instancemanagement==1.1.0
ansys-api-tools-filetransfer==0.1.0
ansys-fluent-core==0.26.1
ansys-fluent-visualization==0.14.0
ansys-meshing-prime==0.6.2
ansys-platform-instancemanagement==1.1.2
ansys-tools-filetransfer==0.1.0
ansys-units==0.3.2
appdirs==1.4.4
beartype==0.19.0
certifi==2024.8.30
charset-normalizer==3.4.0
click==8.1.7
colorama==0.4.6
contourpy==1.3.0
cycler==0.12.1
docker==7.1.0
fonttools==4.54.1
grapheme==0.6.0
grpcio==1.67.0
grpcio-health-checking==1.62.3
idna==3.10
importlib_metadata==8.5.0
joblib==1.4.2
kiwisolver==1.4.7
lxml==5.3.0
matplotlib==3.9.2
nltk==3.9.1
numpy==1.26.4
packaging==24.1
pandas==2.2.3
pillow==11.0.0
platformdirs==4.3.6
pooch==1.8.2
protobuf==4.25.5
psutil==6.1.0
pyparsing==3.2.0
PySide6==6.7.3
PySide6_Addons==6.7.3
PySide6_Essentials==6.7.3
python-dateutil==2.9.0.post0
pytz==2024.2
pyvista==0.44.1
pyvistaqt==0.11.1
pywin32==308
PyYAML==6.0.2
QtPy==2.4.1
regex==2024.9.11
requests==2.32.3
scipy==1.14.1
scooby==0.10.0
shiboken6==6.7.3
six==1.16.0
tqdm==4.66.6
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
vtk==9.3.1
zipp==3.20.2

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the CAD import with runPrime.bat, the documented block model example, and the provided Python client snippet. Trace the server failure through ansys.FM/FM.py and its PyFM import, then compare it with the client failure in lucid/mesh_util.py and core/fileio.py. Done means the example imports the CAD file without the PyFM DLL error or CAD import failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.