Automatic Exporting of Dashboard Image

Automatic Exporting of Dashboard Image

wproctorPG49C
Observer Observer
32 Views
13 Replies
Message 1 of 14

Automatic Exporting of Dashboard Image

wproctorPG49C
Observer
Observer

[ FlexSim 16.1.2 ]

I would like to quickly export all of the dashboard images for experiments. I know how to export the raw data used to generate the images and know that the images can be manually exported to the PNG format. Is there a way, however, to export the image to a file automatically at the end of a run?

Accepted solutions (1)
33 Views
13 Replies
Replies (13)
Message 2 of 14

sam_stubbsYXX86
Community Manager
Community Manager
Accepted solution

So we were able to achieve this by exploring the structure of the dashboard properites panel, and looking at the Save as PNG file. In there it calls the function_s() function which calls a predefined "savePNG" function. So when we took it apart we came up with the following code.:

treenode view = node("/1>Documents/Dashboard/1+/..",views());
function_s(ownerobject(view),"savePNG");

Where the treenode view is a reference to the view of the dashboard. The function_s(ownerobject(view),"savePNG"); executes a function that will bring up a file save window where you can name and save your PNG file.

So call this code at some point in your logic at the end of your runtime, and then when it hits that point it will pop up with the option for you to save the view of your file as a PNG. I've attached the model below with the code snippet in it, so you can try it.

testpngmodel.fsm

Message 3 of 14

jing_chen
Not applicable

Hi, Sam.

Your model works well! But can we save the PNG with some specified name in code instead of bringing up the file save window and naming them one by one?

0 Likes
Message 4 of 14

joerg_vogel_HsH
Mentor
Mentor

Since the capture screen shortcut key "p" was lost in previous Flexsim versions sometime in the past, you can still use external programs with the command:

runprogram(str commandline); // runprogram("c:/myprogram.exe")

For example the program irfanView has some command line options to capture the screen or a rectangle area and save the area in different graphical formats:

i_view32.exe /capture=2 
/convert=c:\capture_$U(%d%m%Y_%H%M%S).jpg

This example from the manual faqs save the screen with a time stamp in the file name.

0 Likes
Message 5 of 14

wproctorPG49C
Observer
Observer

Sam - Thanks for your help with this!

0 Likes
Message 6 of 14

wproctorPG49C
Observer
Observer

Thanks Jorg! This will be helpful! - Bill

0 Likes
Message 7 of 14

noah_zenker
Not applicable

Having a method to specify the name via code rather than interacting every time with a dialog box would be very useful. Is there any guidance on how to do this?

@Sam Stubbs

0 Likes
Message 8 of 14

Jacob_Gillespie
Autodesk
Autodesk

@Noah Zenker, @jing.chen

treenode view = node("/1>Documents/Dashboard/1+/..",views());
treenode graphPanel = node("GraphPanel", ownerobject(view));
string filePath = "C:\\Users\\user.name\\Desktop\\img.png";

// This hides the sizers, you could remove this
for (int i = 1; i <= content(graphPanel); i++) {
	treenode widget = rank(graphPanel, i);
	if (getvarnum(widget, "showingSizers")) 
		function_s(widget, "hideSizers");
}

// This saves the dashboard as a png
viewtofile(graphPanel, filePath);
Message 9 of 14

jing_chen
Not applicable

wow. It is really an interesting method~ Thanks~

0 Likes
Message 10 of 14

noah_zenker
Not applicable

@Sam Stubbs

Is the method you described above still valid in FS18? I tried to run code above and it doesn't seem to do anything anymore.

0 Likes
Message 11 of 14

sam_stubbsYXX86
Community Manager
Community Manager

That's a great question. I know they've made some substantial changes to the Dashboard. It looks like the save to PNG has made some changes as well. @jordan.johnson Do you know how you could accomplish this is 2018?

0 Likes
Message 12 of 14

JordanLJohnson
Autodesk
Autodesk

I used the code given above in 18.0, and it worked fine. The code does assume a couple things, though. First, the path must be correct, with escaped slashes. Second, the dashboard must be open.

While there was a big overhaul to the dashboard library, the dashboard itself didn't change between versions 17 and 18, so this method ought to work.

.


Jordan Johnson
Principal Software Engineer
>

Message 13 of 14

ITAsset
Not applicable

@jordan.johnson do I understand correctly this would only work for the active dashboard that was open? I am trying to export 4 different dashboards but only seem to be able to get the one which is active when I run the code - but I'm not sure that is how it should work or the result of something else I'm doing.

0 Likes
Message 14 of 14

JordanLJohnson
Autodesk
Autodesk

Are the open views visible? If it's tabbed behind something else, I don't think it would work. However, you could try this line of code to activate an open, but possibly tabbed, dashboard:

applicationcommand("activatedockedview", node("/1>Documents/Dashboard/1+/~",views()));

Note that you are activating the ownerobject of the view, rather than just the layer up, as in the previous code example.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes