question

Abhishek K avatar image
0 Likes"
Abhishek K asked Abhishek K commented

How to export HTML on Model Stop?

I am trying to export HTML dashboard on model stop.

When I export it as csv using the code below, it works fine


string curDir = modeldir();

treenode obj = model().find("Tools/Statistics/State Bar"); function_s(obj,"createCSV",curDir+"Dummyresult.csv");

I am unable to find the string that needs to be used in function_s that does the export in HTML format.

Intuitively, I tried "createHTML" , but that does not seem to work.

FlexSim 18.1.1
exporthtmldashboard export
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jordan Johnson avatar image
5 Likes"
Jordan Johnson answered Abhishek K commented

First of all, I would not put export code in the OnModelStop trigger. Does your model have a Stop Time? You could put a user event at that stop time to export the code. That way, as you debug your model, you won't export many useless charts.

Second, a chart doesn't know how to export a complete HTML page. It only knows how to export components, like the bundle data and which js scripts it needs. These four functions all start with getOffline, and are found in MAIN:/project/library/statistics/StatisticObject>behaviour/eventfunctions. You could try calling all four functions (using function_s(obj, "getOffline*")) to see what you get, and then write code that generates html manually.

Another option would be to do what the view does. This requires calling functions on the view, not on the statistics objects:

treenode anActiveDashboard = ownerobject(views().find("active>Documents/Dashboard/1+"));

// the following function is defined in VIEW:/standardviews/statistics/Dashboard>eventfunctions/saveHTML.
// If you don't like the behavior defined here, you could still use the code there to get you started
function_s(anActiveDashboard, "saveHTML", 1); 


· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Abhishek K avatar image Abhishek K commented ·

Thanks for the answer, Jordan.

The model has a stop time and warm up time, and is importing data on Model Open & starts running on Model Open as well. On Stop, I wanted to automatically export visuals since I want to create an automatic task schedule that will open & run the model, then export the visual result in a directory. This is the reason I asked. I understand your point about debugging but at this point I dont think I will create any useless chart.


I tried the "saveHTML" for the views and it works just the way I want, but it still requires a human user to enter file name and save as HTML. Is there anyway that it can automatically save with some file name using function_s ?

1 Like 1 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Abhishek K commented ·

Hi Abishek,

Try this code, which I pulled from the saveHTML code:

treenode anActiveDashboard = ownerobject(views().find("active>Documents/Dashboard/1+"));
int saveAll = 1;
treenode web = 0;

string filePath = modeldir() + "TestOutput.html";

setvarnum(anActiveDashboard, "statDataIndex", 0);
function_s(anActiveDashboard, "generateDashboardData", saveAll, web, 0, getvarnode(anActiveDashboard, "statDataIndex"));
function_s(anActiveDashboard, "generateHTML", filePath, saveAll, web);

This code worked for me. You should be able to easily change the filePath variable.

1 Like 1 ·
Abhishek K avatar image Abhishek K Jordan Johnson ♦♦ commented ·

That worked perfectly.

Thanks a lot, Jordan !

0 Likes 0 ·