How to refresh GUI window?

martin_k5
Not applicable
1 View
7 Replies
Message 1 of 8

How to refresh GUI window?

martin_k5
Not applicable

[ FlexSim 23.1.0 ]

Hi,

I have a model with custom GUI, where I have a reference to GlobalTable. Through this GUI I am able to change GlobalTable's cell color based on value change. This is done without a problem, the cell's color changes, but the visual part is not affected. Even if I press the F5 to refresh the GUI. What I have to do is to save the model and then press the F5 button and the color changes.


Is there any command to do this as it is for combobox (refreshcombobox)?


Thank you,


Martin

0 Likes
Accepted solutions (1)
2 Views
7 Replies
Replies (7)
Message 2 of 8

jason_lightfootVL7B4
Autodesk
Autodesk
Have you tried repaintview() and refreshview() ?
0 Likes
Message 3 of 8

martin_k5
Not applicable

Yes, I have tried that, but without improvement.

The desired goal:

  • - to open model and see the GUI (one cell should be colored)
  • - then to change the cell's color and based on some action (command) refresh the view and see the changed color in the cell
  • 1691410929277.png


I am also attaching the model if you would be able to help me more?


Thank you,


Martin


ColorGT_demo.fsm

0 Likes
Message 4 of 8

jonah_kendellR47TC
Autodesk
Autodesk
Accepted solution

The main problem is that you are changing the FlexScript code then are not building it. When you change a treenode that has FlexScript data, you must then Build the Node FlexScript or Build All FlexScript in order for your changes to be complied. (This is done when you hit Save) You can add a Build FlexScript button to your toolbar in Global Preferences > Customize Toolbar, or you can right click on a treenode and select Build > Build Node FlexScript. But I'd recommend that you use the buildnodeflexscript() command. I ran this script which uses that command and I referenced the Col2Units node in the GUI, and the cell changed to the correct color in "bgColor" whenever I ran the script.

buildnodeflexscript(Model.find("MODEL:/Tools/GUIs/test/table2>style/FS_CELL_FORMATTING/Col2Units"));
Object gui = Model.find("MODEL:/Tools/GUIs/test");
refreshview(gui);


Message 5 of 8

martin_k5
Not applicable

Thank you for your detailed answer. I did not know about this and it works. It solved the problem when you change manually/by code the treenode's FlexScritp and you want to see the desired change in the GUI. But what if I have dashboard with GUI class and change the treenode? As I do so, the GUI class in dashboard does not show the change only the freshly opened GUI (done by your code).


I am also attaching the model, would you be so kind to help?


Thank you,

Martin

ColorGT_demo.fsm

0 Likes
Message 6 of 8

jonah_kendellR47TC
Autodesk
Autodesk

For a dashboard table GUI, you need to refresh the dashboard widget. So in all, you'll need to build the Node FlexScript of the treenode you changed, get the Dashboard widget with getdashboardcontrol("your_gui_ID"), call the Refresh function on the ownerobject of the widget, then refresh the view.

buildnodeflexscript(Model.find("MODEL:/Tools/GUIs/test/table2>style/FS_CELL_FORMATTING/Col2Units"));
Object dash = getdashboardcontrol("gui_class"); 
function_s(ownerobject(dash), "refresh");
refreshview(dash);

I had to close your dashboard and open it again to get the Properties panel to focus on the widget so you can see the gui ID.

colorgt-demo_JK.fsm

Message 7 of 8

martin_k5
Not applicable
Hi,


sorry for late response. I ran your model and that is exactly what I was looking for. Still I have one question: Is is possible to deselect the GUI in dashboard after running the refresh command (the provided code)?


Thank you,


Martin

0 Likes
Message 8 of 8

jason_lightfootVL7B4
Autodesk
Autodesk
0 Likes