How to export the worksheet view (say Force Convergence graph) as an image via ACT in Mechanical?

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 206
100 Comments 25 Answers Second Anniversary 25 Likes
✭✭✭✭
edited November 13 in Structures

How to export the worksheet view (say Force Convergence graph) as an image via ACT in Mechanical?

Tagged:

Best Answers

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 206
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    Click on Solution Information in Mechanical --> Change Solution Output to Force Convergence --> Toggle Worksheet View --> and run the below script in Mechanical in ACT Console. This would create an image of the Force Convergence plot in D drive.

    enter image description here

    graphics = ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.Worksheet)
    
    width = graphics.ControlUnknown.Width()
    height = graphics.ControlUnknown.Height()
    Pane = ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.Worksheet)
    Pane.CommandContainer.WindowRect.Left
    
    initial_x = Pane.CommandContainer.WindowRect.Left
    initial_y = Pane.CommandContainer.WindowRect.Top
    
    final_x = initial_x + width
    final_y = initial_y + height
    
    # Take screenshot
    import clr
    import os
    import sys
    clr.AddReference("System.Windows.Forms")
    clr.AddReference("System.Drawing")
    
    from System.Drawing import Bitmap,Graphics,Point,Size
    from System.Windows.Forms import(
        Application,Button,Form,FormWindowState,
        PictureBox,Screen)
    
    bmp = Bitmap(final_x-initial_x, final_y-initial_y)
    g = Graphics.FromImage(bmp)
    g.CopyFromScreen(initial_x,initial_y, 0, 0, Size((final_x-initial_x), (final_y-initial_y)))
    bmp.Save(r"D:\test.png")
    g.Dispose()
    
  • Vishnu
    Vishnu Member, Employee Posts: 222
    100 Comments 100 Likes Second Anniversary Name Dropper
    ✭✭✭✭
    Answer ✓

    We can add this to automatically navigate to force convergence plots before executing above script:

    Mechanical --> Solution Output to Force Convergence --> Worksheet View

    solution = ExtAPI.DataModel.Project.Model.GetChildren(DataModelObjectCategory.Solution,True)[0]
    solution.SolutionInformation.SolutionOutput = SolutionOutputType.ForceConvergence
    ExtAPI.DataModel.Tree.Refresh()
    solution.SolutionInformation.Activate()
    

Answers

  • Matthias
    Matthias Member Posts: 10
    Name Dropper First Anniversary First Comment
    **

    How can the export of the force convergence graph be achieved during a design point update?

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 206
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭

    Hello @Matthias , unfortunately the solution in this post is not applicable for batch mode (design point update). For DP study, I would consider using file.gst in the solver directory, which can be plotted in MAPDL gui or, one could use some simple python script with Python Code object (after solve callback) to extract just the 2 columns corresponding to the Force Convergence graph and make a matplot lib curve for example.