How to export the worksheet view (say Force Convergence graph) as an image via ACT in Mechanical?
How to export the worksheet view (say Force Convergence graph) as an image via ACT in Mechanical?
Best Answers
-
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.
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()
0 -
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()
2
Answers
-
How can the export of the force convergence graph be achieved during a design point update?
0 -
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.
0