How can I use JScript to save one image for each time point in the solution for a particular result item?
/**************************************************/ /* saveImagesOverTime.js */ /* - a script to save images for all */ /* time points of one result object */ /* */ /* Aaron C Acton */ /* Technical Services Engineer, ANSYS Inc. */ /* 08/31/2010 */ /**************************************************/ // set the directory where you would like the images to be stored var directory = "C:scratch", filename; // set some global variables var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); var obj = DS.Tree.FirstActiveObject; // if the directory exists if(fileSystem.FolderExists(directory)) { // if the selected item is a result object if(obj.Class == DS.Script.id_Result || obj.Class == DS.Script.id_CustomResult) { // set the result driver to Result Set obj.SetDriver = 2; // loop over results sets for(var rset = 1; rset <= obj.Parent.NumResultTimePoints; rset+=1) { // set the time obj.SetNumber = rset; DS.Script.doRetrieveResults (); // set the filename filename = directory + obj.Parent.Parent.Parent.Name + " - " + obj.Parent.Parent.Name + " - " + obj.Name + " (" + padNum(rset) + ") " + ".png"; // store the image DS.Graphics.ImageCaptureControl.Write( 0, filename ); } // if a result object is not selected } else { // alert the user WBScript.Out("Please select a result object.", true); } // if the directory does not exist } else { // alert the user WBScript.Out("Please create the directory " + directory, true); } function padNum(num) { var str = num.toString(); while (str.length < 3) { str = "0" + str; } return str; } |
||
|