How save results picture with a script

PierreLCV Member Posts: 33
First Comment Name Dropper
edited June 5 in Structures

Hello everyone,
I am currently working on a 2D FEA thermal simulation on Ansys Mechanical for which I am using a script as I have a lot of different boundary conditions to use. I have field temperature I would like to save at each iteration of my script, see just after :

This last field being the result of the user defined expression.

The question is then simple, how save this picture at each iteration of my script ? I know that I can save the current image (I mean the one which appears at the screen) with the following command but how specify that I want to save the picture of the user defined result ?

Thank you !


  • PierreLCV
    PierreLCV Member Posts: 33
    First Comment Name Dropper

    No idea ? I don't think I'm the only one who needs to save the results of my simulations?

    Thank you,

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 130
    First Answer Name Dropper First Anniversary Ansys Employee
    edited June 7


    I hope the below does what you want:

    model = ExtAPI.DataModel.Project.Model
    user_defined = solution.AddUserDefinedResult()
    user_defined.Expression = r'UY'
    Tree.Activate(user_defined) # activate the result in the tree (so it becomes visible in the window)
    image_settings = Ansys.Mechanical.Graphics.GraphicsImageExportSettings()
    image_settings.CurrentGraphicsDisplay = True
    ExtAPI.Graphics.ExportImage('D:/mytestimage.png', GraphicsImageExportFormat.PNG, image_settings)

    The user_defined expression can be seen in the ui and the results (top left).

    If one wants instead a screenshot of the whole screen and thus of the whole UI, and not only the model window inside mechanical where the results are, then the below post might be of help:

    Thank you and kind regards


  • PierreLCV
    PierreLCV Member Posts: 33
    First Comment Name Dropper

    Dear Erik,
    Thank you very much for your answer ! I will try it and will come back to you :). Sorry for the delay of my answer I do not know how but I have missed your answer.

    Best regards,