Results
The Results node contains nodes for Datasets, Derived Values, Tables, Plot Groups, Export, and Reports. As soon as a solution is obtained, a set of Plot Group nodes are automatically created. In the example of Heat Transfer in Solids, when setting up such an analysis in the Model Builder, two Plot Group nodes are added automatically. The first one is a Surface plot of the Temperature and the second one is a Contour plot showing the isothermal contours. Below you will see how to set up the corresponding plots manually.
First create a 2D plot group with tag pg1:
model.result().create("pg1", "PlotGroup2D");
Change the Label of the Plot Group:
model.result("pg1").label("Temperature (ht)");
Use the dataset dset1 for the Plot Group:
model.result("pg1").set("data", "dset1");
Create a Surface plot for pg1 with settings for the color table used, the intra-element interpolation scheme, and the dataset referring to the parent of the Surface plot node, which is the pg1 node:
model.result("pg1").feature().create("surf1", "Surface");
model.result("pg1").feature("surf1").label("Surface");
with(model.result("pg1").feature("surf1"));
  set("colortable", "ThermalLight");
  set("smooth", "internal");
  set("data", "parent");
endwith();
Now create a second 2D plot group with contours for the isotherms:
model.result().create("pg2", "PlotGroup2D");
model.result("pg2").label("Isothermal Contours (ht)");
with(model.result("pg2"));
  set("data", "dset1");
endwith();
model.result("pg2").feature().create("con1", "Contour");
model.result("pg2").feature("con1").label("Contour");
with(model.result("pg2").feature("con1"));
  set("colortable", "ThermalLight");
  set("smooth", "internal");
  set("data", "parent");
endwith();
Finally, generate the plot for the Plot Group pg1:
model.result("pg1").run();
To find the maximum temperature, add a Surface Maximum subnode to the Derived Values node as follows:
First create the Surface Maximum node with tag max1:
model.result().numerical().create("max1", "MaxSurface");
Note that in this context the method corresponding to the Derived Values node is called numerical.
Next, specify the selection. In this case there is only one domain 1:
model.result().numerical("max1").selection().set(new int[]{1});
Create a Table node to hold the numerical result and write the output from max1 to the Table:
model.result().table().create("tbl1", "Table");
model.result().table("tbl1").comments("Surface Maximum 1 {max1} (T)");
model.result().numerical("max1").set("table", "tbl1");
model.result().numerical("max1").setResult();
Use Record Code or any of the other tools for automatic generation of code to learn more about the syntax and methods for Results.
Using Parameterized Solutions in Results
The code below changes the visualization of a plot group pg1 by setting the property looplevel, which controls the solution parameter, to the string variable svar.
with(model.result("pg1"));
  set("looplevel", new String[]{svar});
endwith();
model.result("pg1").run();
The property looplevel has a central role in accessing parameterized solutions. Its argument is a 1D string array with one index per "loop level" in a study. The different loop levels correspond to the different nested parameters in a parametric sweep with multiple parameters.
Loading Data to Tables
By using the loadFile method you can import data into a table and then display it using a results table form object or a table surface plot. The following example demonstrates loading data from an Excel file into a table and visualizing the contents using a table surface plot. The file in this example is assumed to be imported, in an application, using a file import form object with a file declaration file1 as the File Destination.
model.result().table("tbl1").loadFile("upload:///file1", "", cells);
/*
  The string variable cells contains the spreadsheet selection to be   imported, for example A1:J7.
 
  The following code creates a plot group pg1 with a table surface plot.   This code is not needed if the embedded model already contains a table   and a table surface plot.
*/
 
model.result().create("pg1", 2);
model.result("pg1").create("tbls1", "TableSurface");
with(model.result("pg1").feature("tbls1"));
  set("table", "tbl1");
endwith();
with(model.result("pg1").feature("tbls1"));
  set("dataformat", "cells");
endwith();
model.result("pg1").feature("tbls1").create("hght1", "TableHeight");
with(model.result("pg1").feature("tbls1").feature("hght1"));
  set("view", "view3");
endwith();
with(model.view("view3").camera());
  set("viewscaletype", "manual");
  set("xscale", "1");
  set("yscale", "1");
  set("zscale", "1");
endwith();
// The following line is needed to update the plot
model.result("pg1").run();