ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
||||
|
||||
Model Startup Code
I am trying to find a way to execute code when I open my model.
The menu 'Model Startup Code' under Tools describes exactly what I am trying to do. However this code is executed after compile (as the gui tells me). Since we are not compiling anymore in Flexsim4 this code will never be executed. Would it be possible to change the logic of this menu, so that it actually is executed at model startup? The code is already flexscript, so it should be possible? If anyone knows how to execute code at startup, please let me know. Thanks, Lolke |
#2
|
||||
|
||||
Lolke,
There is a thread called Start Flexsim and model from externally via a batch file under Technical Support / External Connection / Other Connections. It is not exactly what you are looking for but it describes a way how to execute some code by using the StartupRT.txt. I would think, that you want the code you like to execute save in your model and you do not want to change any external files. So I agree it would be nice to have way to execute some code in your model without compile the model, like the Model Startup Code . Maybe there is a way and we just do not know it .
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions." |
#3
|
||||
|
||||
Model Startup Code is not a good title
We realize that Model Startup Code is not a good title and that it really should have been called Post Compiling Code or something like that. It is on our future development list to allow users to define Model Load Code (not sure this is what it will be called). For now, what I do is add a node in my model Tools folder, give it object data, add a node to its object data tree, give it text data, give the new node the name OnLoad, toggle the node flexscript, build flexscript, save model. Next time you load the model, any code you wrote in the OnLoad node's text data will execute.
|
#4
|
||||
|
||||
Cliff's suggestion should work, however, be aware that if you do it as he mentioned, the OnLoad code will fire whenever you load anything, not just your model. So the code will be executed when you load the model, but also if you, let's say, load a user library while the model is open, or if you load a tree file anywhere into the model, the OnLoad code will also be fired again at that point. As Cliff said, it's on our list to add a Model Load script that just fires when you open the model.
|