question

SudheerReddy avatar image
0 Likes"
SudheerReddy asked Jordan Johnson commented

Dashboard objects

With reference to the question listed below

https://answers.flexsim.com/questions/78567/cleaning-up-orphaned-statistics-objects.html

I am using the below code.

But I am getting widgets.length as Zero i.e. there are no subnodes for widgets. I understood widgets in the below code are all the charts in the respective dashboard. If not what is the widget in the below code?

I am attaching the model for reference

dashboard.fsm

treenode statisticsFolder = Model.find("Tools/Statistics");
Array usedStatsObjects;
var dashboards = Model.find("Tools/Dashboards").subnodes;
for (int d = 1; d <= dashboards.length; d++) {
	var widgets = dashboards[d].subnodes;
	for (int w = 1; w <= widgets.length; w++) {
		Object widget = widgets[w];
		treenode saver = widget.attrs.find("saver");
		treenode storedNode = widget.attrs.find("stored");
		if (saver && saver.value == "DashboardWebStatGraph" && storedNode) {
			var storedLinks = storedNode.subnodes;
			for (int s = 1; s <= storedLinks.length; s++) {
				treenode linkedNode = storedLinks[s].find("+/~");
				if (linkedNode && linkedNode.up == statisticsFolder) {
					usedStatsObjects.push(linkedNode);
				}
			}
		}
	}
}
var statsObjects = statisticsFolder.subnodes;
for (int i = 1; i <= statsObjects.length; i++) {
	treenode statsObject = statsObjects[i];
	if (usedStatsObjects.indexOf(statsObject) <= 0) {
		print(statsObject);
		// statsObject.destroy();
	}
}
FlexSim 20.0.0
dashboards
das.jpg (72.3 KiB)
dashboard.fsm (51.4 KiB)
· 1
5 |100000

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

SudheerReddy avatar image SudheerReddy commented ·
0 Likes 0 ·

1 Answer

·
Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Jordan Johnson commented

You must close the dashboards before running the script (as mentioned in the original question). Otherwise, the widget nodes are missing. Also, be sure to review the follow-up comments on the original question for better information.

· 2
5 |100000

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

SudheerReddy avatar image SudheerReddy commented ·

@jordan.johnson. Thanks for the answer. It helped me.

Following is the one add question I have for this

If dashboards are opened why is the widget nodes are missing. It is only for Dashboards where we have to close before running to get nodes or it is similar for other tools as well.

-1 Like -1 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ SudheerReddy commented ·

The dashboards are unique in FlexSim, since the view can be edited while it is open. For example, you can move the position of widgets. So when the dashboard opens, it consumes the widget information, and creates the view. You can change the view around, and then close the view. The new widget entries will reflect any changes you made.

I don't know of any other tool or feature that has this behavior.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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