Tom David
09-11-2007, 09:02 AM
During the distributor training Anthony Johnson showed an example how to start Flexsim from externally.
I thought this might be interesting for the whole community so I made an example for myself with a batch file and some documentation. The other way to start Flexsim externally could be to use *.vbs. which Anthony showed at the training.
Maybe someone else is in the mood to explain or make an example for this.
Because I got once a Blue Screen during my testing I like to mention that I am not responsible for anything what will happen if you try this stuff. I know this is already clear because this is a forum post but I like to say it at least once ;).
The Batch file I use (StartFlexsimAndModelViaBatchFile_TD.bat) looks like this:"C:\Program Files\Flexsim4\program\flexsimrunner.exe" "C:\Program Files\Flexsim4\userprojects\ StartFlexsimAndModelViaBatchFile_TD.fsm"
To execute code while loading the StartupRT.txt is used (found in the /program directory).
I recommend to make a backup of this file.
The general idea is to execute a node function of a node in the model.
In my example the node is under /Tools and called StartupRTtxt.
The following code was modified and added to the StartupRT.txt at the end:
if(openingmodel)
nodefunction(node("MAIN:/project/exec/globals/nodefunctions/openmodelcode"));
if(objectexists(node("/Tools/StartupRTtxt",model())))
{
nodefunction(node("/Tools/StartupRTtxt",model()));
}
if(openinglibrary)
loaduserlibrary(openfile,0,1);
repaintall();
Be aware that there is already code and I just added the bold text.
Create the node StartupRTtxt and toggle the node as Flexscript and Build Flexscript.
Following files are in the zip archive (StartFlexsimAndModelViaBatchFile_TD.zip):
/userprojects/Logo_FlexsimD.bmp
/userprocjets/StartFlexsimAndModelViaBatchFile_TD.bat
/userprocjets/StartFlexsimAndModelViaBatchFile_TD.fsm
/program/startupRT_TD.txt (which has to be renamed to startupRT.txt)
I did not add the paths into the archive because I do not want that by accident someone overwrites his startupRT.txt. So you need to put these files in the above described directories by yourself.
I am sure this gives the community an idea how to do the external start.
Because all Flexscript can be used in the node you can do whatever you want.
In combination with cmdcompile() and the ModelStartupCode I see some more scenario which could be build. :eek:
Hopefully my little post will start a discussion about this subject, because I am ready to learn more about it. I appreciate every comment and every new idea. :)
Thanks in advance
tom the (A)tom
I thought this might be interesting for the whole community so I made an example for myself with a batch file and some documentation. The other way to start Flexsim externally could be to use *.vbs. which Anthony showed at the training.
Maybe someone else is in the mood to explain or make an example for this.
Because I got once a Blue Screen during my testing I like to mention that I am not responsible for anything what will happen if you try this stuff. I know this is already clear because this is a forum post but I like to say it at least once ;).
The Batch file I use (StartFlexsimAndModelViaBatchFile_TD.bat) looks like this:"C:\Program Files\Flexsim4\program\flexsimrunner.exe" "C:\Program Files\Flexsim4\userprojects\ StartFlexsimAndModelViaBatchFile_TD.fsm"
To execute code while loading the StartupRT.txt is used (found in the /program directory).
I recommend to make a backup of this file.
The general idea is to execute a node function of a node in the model.
In my example the node is under /Tools and called StartupRTtxt.
The following code was modified and added to the StartupRT.txt at the end:
if(openingmodel)
nodefunction(node("MAIN:/project/exec/globals/nodefunctions/openmodelcode"));
if(objectexists(node("/Tools/StartupRTtxt",model())))
{
nodefunction(node("/Tools/StartupRTtxt",model()));
}
if(openinglibrary)
loaduserlibrary(openfile,0,1);
repaintall();
Be aware that there is already code and I just added the bold text.
Create the node StartupRTtxt and toggle the node as Flexscript and Build Flexscript.
Following files are in the zip archive (StartFlexsimAndModelViaBatchFile_TD.zip):
/userprojects/Logo_FlexsimD.bmp
/userprocjets/StartFlexsimAndModelViaBatchFile_TD.bat
/userprocjets/StartFlexsimAndModelViaBatchFile_TD.fsm
/program/startupRT_TD.txt (which has to be renamed to startupRT.txt)
I did not add the paths into the archive because I do not want that by accident someone overwrites his startupRT.txt. So you need to put these files in the above described directories by yourself.
I am sure this gives the community an idea how to do the external start.
Because all Flexscript can be used in the node you can do whatever you want.
In combination with cmdcompile() and the ModelStartupCode I see some more scenario which could be build. :eek:
Hopefully my little post will start a discussion about this subject, because I am ready to learn more about it. I appreciate every comment and every new idea. :)
Thanks in advance
tom the (A)tom