ansys / pymechanical

Pythonic interface to Ansys Mechanical ™
https://mechanical.docs.pyansys.com/
MIT License
34 stars 17 forks source link

Issues using IronPython libraries in CPython #515

Closed landon-kanner closed 3 months ago

landon-kanner commented 9 months ago

🔍 Before submitting the issue

🐞 Description of the bug

Using the Python modules that are distributed with the installation of Mechanical per https://mechanical.docs.pyansys.com/version/stable/user_guide_embedding/libraries.html does not work when there are syntax differences between IronPython and CPython. For example: image

📝 Steps to reproduce

mech_db_file_path = r"D:\No_Backup\embedded_mech_to_ADR\test_case1.mechdat"
version = 241
from ansys.mechanical.core import App, global_variables
from ansys.mechanical.core.embedding import add_mechanical_python_libraries
app = App(version=version )
add_mechanical_python_libraries(version)
app.open(mech_db_file_path)
import materials
for part in ExtAPI.DataModel.GeoData.Assemblies[0].Parts:
        for body in part.Bodies:
            if body.Suppressed:
                continue
            mat = body.Material
MatCategories = materials.GetListMaterialProperties(mat)

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

24.1

🐍 Which Python version are you using?

3.10

📦 Installed packages

ansi2html==1.8.0
ansys-api-mechanical==0.1.1
ansys-api-platform-instancemanagement==1.0.0
ansys-dynamicreporting-core==0.5.0
ansys-mechanical-core==0.10.4
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc1
ansys-templates==1.6.1
ansys-tools-path==0.3.1
appdirs==1.4.4
arrow==1.3.0
asgiref==3.7.2
attrs==23.1.0
binaryornot==0.4.4
build==1.0.3
certifi==2023.7.22
cffi==1.15.1
chardet==5.2.0
charset-normalizer==3.2.0
cleo==0.8.1
click==8.1.6
clikit==0.6.2
clr-loader==0.2.6
colorama==0.4.6
contourpy==1.1.1
cookiecutter==2.2.3
crashtest==0.3.1
cycler==0.12.1
dash==2.13.0
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
distlib==0.3.7
Django==4.2.7
docutils==0.20.1
filelock==3.12.2
Flask==2.2.5
fonttools==4.43.1
gitdb==4.0.11
GitPython==3.1.40
grpcio==1.57.0
idna==3.4
importlib-metadata==6.8.0
install==1.3.5
isort==5.12.0
itsdangerous==2.1.2
jaraco.classes==3.3.0
Jinja2==3.1.2
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
keyring==24.3.0
kiwisolver==1.4.5
loguru==0.7.2
markdown-it-py==3.0.0
MarkupSafe==2.1.3
matplotlib==3.8.0
mdurl==0.1.2
more-itertools==10.1.0
nest-asyncio==1.5.7
nh3==0.2.14
numpy==1.26.0
packaging==23.1
pastel==0.2.1
Pillow==10.0.1
pkginfo==1.9.6
platformdirs==3.9.1
plotly==5.16.1
pooch==1.7.0
protobuf==3.20.3
pyadr==0.19.0
pyansys-docker==5.0.4
pycparser==2.21
Pygments==2.17.1
pylev==1.4.0
pyparsing==3.1.1
pypng==0.20220715.0
pyproject-toml==0.0.10
pyproject_hooks==1.0.0
PySide6==6.5.2
PySide6-Addons==6.5.2
PySide6-Essentials==6.5.2
python-dateutil==2.8.2
python-slugify==6.1.2
pytz==2023.3.post1
pyvista==0.42.3
pywin32==306
pywin32-ctypes==0.2.2
PyYAML==6.0.1
readme-renderer==42.0
referencing==0.30.2
requests==2.31.0
requests-toolbelt==1.0.0
retrying==1.3.4
rfc3986==2.0.0
rich==13.7.0
rpds-py==0.9.2
scipy==1.11.3
scooby==0.7.4
shiboken6==6.5.2
six==1.16.0
smmap==5.0.1
sqlparse==0.4.4
tenacity==8.2.3
text-unidecode==1.3
toml==0.10.2
tomli==2.0.1
tqdm==4.66.1
twine==4.0.2
types-python-dateutil==2.8.19.14
typing_extensions==4.7.1
tzdata==2023.3
urllib3==1.26.18
virtualenv==20.24.1
vtk==9.2.6
websocket-client==1.6.4
Werkzeug==2.2.3
win32-setctime==1.1.0
zipp==3.16.2
koubaa commented 9 months ago

This is reproducible inside Mechanical using CPython scripting. I filed an issue in Mechanical's internal issue tracker to be resolved in future releases. Until then, maybe we can come up with a workaround.

koubaa commented 3 months ago

This was fixed in 2024R2. @dipinknair this should be part of the KIL for previous releases