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
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(); } }