In Workbench Simulation, results can be exported to image files one at a time. How can I create and save a batch of PNG images, one for each result in the Solution branch?
Please try the attached script (JScript). To run it, choose "Tools" > "Run Macro". It should run through each result item in the tree, and save all images to the folder of your choice. You can edit the scriptfile to change the directory to be whatever you want (currently hardcoded to C:images). Try to avoid opening other windows on top of Workbench during execution, as the foreground window may be included in the final images. /**************************************************/ /* saveImages.js */ /* - a script to save all result images */ /* */ /* 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 oScript = WB.AppletList.Applet( "DSApplet" ).App.Script; var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); var nodeList = oScript.tv.Nodes; var id_Result = 520; // if the directory exists if(fileSystem.FolderExists(directory)) { // loop thru each tree node for(var k = 1; k <= oScript.tv.Nodes.Count; k++) { // make sure it is expanded nodeList(k).Expanded = true; // if we land on a result item if(nodeList(k).Tag.Class == id_Result) { // select the current tree item oScript.tv.selectedItem = nodeList(k); // set the filename filename = directory + nodeList(k).Parent.Parent.Parent.Tag.Name + " - " + nodeList(k).Parent.Parent.Tag.Name + " - " + nodeList(k).Tag.Name + ".png"; // store the image DS.Graphics.ImageCaptureControl.Write( 0, filename ); } } // if the directory does not exist } else { // alert the user WBScript.Out("Please create the directory " + directory, true); } |
||
|