How to take a ScreenShot of your Mechanical Application
You might need to create Screen Shot of the graph or Table sometimes. You can get the coordinates and use the below script.
Best Answers
-
The below Script Saves 2 PNG screen captures in your / Drive
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) UserFiles="D:" Fname="sample.png" bmp=Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height) g=Graphics.FromImage(bmp) g.CopyFromScreen(0,0,0,0,bmp.Size) bmp.Save(os.path.join(UserFiles,Fname+".png")) g.Dispose() Fname="PartScreen.png" bmp=Bitmap(550,1000) g=Graphics.FromImage(bmp) g.CopyFromScreen(0,0,0,0,Size(550,50)) bmp.Save(os.path.join(UserFiles,Fname+".png")) g.Dispose()
1 -
Another solution, though not ideal either, is to use Mechanical's report generator. This creates an .html file with a subfolder that contains screenshots of result data plots. The images can then be reused as needed.
The report generation can be triggered through jscript ("fileName" should be replaced by string of file saving path and name):
var DS = WB.AppletList.Applet("DSApplet").App;
DS.Script.doReportPreviewWindow()
var DS = WB.AppletList.Applet("DSApplet").App;
var publishType=2;
var fname="""fname""";
DS.Script.publishReport(fname , publishType);
6
Answers
-
Warning. All the methods exposed here use unsupported/undocumented commands. There is no guarantee that the script will work and/or that the APIs will not change in between versions. Use at your own risk.
0