Export screenshot of result for each result in the tree

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 741
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

Using ACT, how can I export a screenshot of each result inserted in the Mechanical tree?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 741
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓

    The following code can be used :

    import os
    setting2d = Ansys.Mechanical.Graphics.GraphicsImageExportSettings()
    setting2d.Resolution = GraphicsResolutionType.HighResolution
    setting2d.Width = 838
    setting2d.Height = 392
    setting2d.Background = GraphicsBackgroundType.White
    setting2d.CurrentGraphicsDisplay = False
    imagePath = "C:\Users\Test\" # change directory as needed
    
    solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solution # reference solution
    results = solution.GetChildren(DataModelObjectCategory.Result,True) # get list of results in solution
    for result in results:
        result.Activate()
        totalPath = os.path.join(imagePath) + result.Name+'.png'
        ExtAPI.Graphics.ExportImage(totalPath, GraphicsImageExportFormat.PNG, setting2d)