Export screenshot of result for each result in the tree

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    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)