Minimum requirements to include enums in embedded instance

Hey everyone,
I am currently using an embedded instance of Mechanical in Python. I use the following code to include access to global variables:

from ansys.mechanical.core import App, global_variables
app = mech.App(version=231)
globals().update(global_variables(app))

Then I discovered, that enums are still not available using this method. The help page mentions setting the second argument of the global_variables function to True:

globals().update(global_variables(app, True))

However, this results in the following error when trying to run the code: TypeError: global_variables() takes 1 positional argument but 2 were given

As you can see above, I am running ANSYS version 23r1. Checking the packages in my virtual environment says that my ansys-mechanical-core is version 0.10.2 (help page says at least 0.10) and for the pyansys package 2024rc1 is listed on my end.

Is my 2023r1 version of the app an issue here or is there another problem I am overlooking?

Thanks for your help!

Best Answer

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 859
    500 Comments Photogenic Name Dropper Solution Developer Community of Practice Member
    ✭✭✭✭
    Answer ✓

    Hi @rabe , I'm under the impression here that the issue is that your version of the ansys-mechanical-core package is too old. This feature was treated in this PR, so I believe at least v0.10.3 is needed.

Answers

  • rabe
    rabe Member Posts: 5
    First Comment Name Dropper
    **

    Hi @Pernelle Marone-Hitz , you are right and I updated the ansys-mechanical-core package manually using pip. For anyone interested, here is what I entered in my PyAnsys virtual environment:

    pip install -U ansys-mechanical-core
    

    Even though pip complained about conflicting dependencies with pyansys 2024.1rc1, it works fine now and I can use enums properly.

    Thanks again!