question

ShabDz avatar image
0 Likes"
ShabDz asked ·

How to run a custom code when it's required (by clicking a button)?

Hi all,

Is there any way to run a code when the user want to? I'm looking for a way to create a button executing the custom code when it's needed. Model Triggers (e.g., On Run Start) doesn't work for my problem.

Any help is appreciated.

Thanks,

custom code
5 |100000 characters needed characters left characters exceeded

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

Joshua S avatar image
1 Like"
Joshua S answered ·

Create a dashboard then double click in the empty space. Add a button then add you code to the OnPress trigger.


pic1.png (13.4 KiB)
pic2.png (13.2 KiB)
· 5
5 |100000 characters needed characters left characters exceeded

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

Hello @Joshua S , thanks for the information, I have the next question..

Do you know how i can do the same in a GUI? and also I want to add information in a global table using the GUI in order to "fill" a custom table before to start the GUI..and if is not filled , the GUI will not start..and as well for finish the GUI.

Could you send me and example if is possible please?

Thx

R.V

0 Likes 0 ·

Can you explain a little more, there is some looping in your logic you shared. Step by step would be helpful.

0 Likes 0 ·

Hi Joshua ,

please see below:

1-User Open a model in flexsim

2-GUI is open when model open

3-GUI ask user to "add information" and this information will be save in "global table" 8 rows and 1 colums of data. (the first 4 datas will be selected by one list and the other 8 datas will need to added manually)

4- If the global table is empty the GUI will mention that is "pending to add information" but if the datas are filled (global talle is differnt from 0) this will continue to the next step (5)

5-Open a new GUI if the datas from step 4 are ok, which include:

5.1-Run custom code in a button ( i alredy have the custom code, but we can change color object as example)
Button name:

-Create report

-Run simulation report

-create new report?

-clean datas

-Exit model

When they click on "exit model" or "clean datas" the datas saved in the global table will need to be exported to CSV as well creating a new "backup table" from the original datas from "global table"(step3)

5.2- Change parameters of the model objects typing the datas manually for example:

-change datas from an Object(example CT of procesor)

Please let me know if you have any question.

Thanks a lot for your support

R.V

0 Likes 0 ·
Show more comments
Raul Vazquez avatar image
0 Likes"
Raul Vazquez answered ·

Thanks Joshua , ill take a look

5 |100000 characters needed characters left characters exceeded

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

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.