How to export tabular data and local maximum and local minimum values ​​in energy probe using Python

sunyroy
sunyroy Member Posts: 11
First Comment Name Dropper
**
edited December 2024 in Structures


As shown in the figure, I need to export the data from these two places. How should I implement it with Python and run it in visual studio?

Also is there a way to realize the overall export operation of the table in the Python environment?

Answers

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 285
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited December 2024

    Hi

    Perhaps start and try to use this in mechanical scripting inside the automation/script console or in a python code :

    mprobe=ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.EnergyProbe)[0]
    mprobe.Activate()

    and then see this post to get the values of the tabular data:

    https://discuss.ansys.com/discussion/255/how-to-access-tabular-data-using-act

    then perhaps loop/look through data to find what you want perhaps and write to a text file as needed to export.

    Not sure if the above will always work if you run many simulations (say via batch)

  • sunyroy
    sunyroy Member Posts: 11
    First Comment Name Dropper
    **

    @Erik Kostson said:
    Hi

    Perhaps start and try to use this in mechanical scripting inside the automation/script console or in a python code :

    mprobe=ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.EnergyProbe)[0]
    mprobe.Activate()

    and then see this post to get the values of the tabular data:

    https://discuss.ansys.com/discussion/255/how-to-access-tabular-data-using-act

    then perhaps loop/look through data to find what you want perhaps and write to a text file as needed to export.

    Not sure if the above will always work if you run many simulations (say via batch)

    Hello, thank you very much for your answer, but when I run this code in visual studio software, it prompts "NameError: name 'MechanicalPanelEnum' is not defined". Is there any way to export this data in Python 3.9 environment?

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 128
    100 Comments 25 Likes Second Anniversary 5 Answers
    ✭✭✭✭

    @sunyroy You can import those global variable like this:

    app.update_globals(globals(), True)

    https://mechanical.docs.pyansys.com/version/stable/user_guide_embedding/globals.html#globals