question

Sebastien avatar image
0 Likes"
Sebastien asked Sebastien commented

Change script of runscript directly in cmd for silent running

Hi !
I am running FlexSim silently with Python executing this command from @Ben Wilson :

  
                 
  1. "C:\Program Files\FlexSim 2016\program\flexsim.exe" 
  2. "C:\Users\username\Documents\Flexsim 16 Projects\test.fsm" /maintenance
  3. nogui_disablemsg_runscript /scriptpath C:\myscript.txt


Yet I would like to change the script, not in a file but directly in the command line, like this

EDIT:

  1. "C:\Program Files\FlexSim 2016\program\flexsim.exe"
  2. "C:\Users\username\Documents\Flexsim 16 Projects\test.fsm" /maintenance
  3. nogui_disablemsg_runscript 'resetmodel(); runspeed(10000); go();Table("tableName")[1][1] = 1;'

I tried several ways but it did not work and I cannot find the documentation for the command line interface execution of FlexSim. Is this possible ? This would make it easier for me as I'd just need to change input parameters of the model directly in Python instead of saving a temporary file for each simulation I want to run.

FlexSim 20.2.3
pythoncommand linerunscript
· 1
5 |100000

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

Kavika F avatar image Kavika F ♦ commented ·

Hey @Sebastien , I don't think this is possible, primarily because the documentation doesn't mention anything about it.

0 Likes 0 ·

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Sebastien commented

Use the commandlineparam() and executestring() commands to pass an arbitrary parameter to FlexSim and execute it as a string.

myscript.txt:

executestring(commandlineparam("myparam"));

command.bat:

"C:\Program Files\FlexSim 2016\program\flexsim.exe" 
"C:\Users\username\Documents\Flexsim 16 Projects\test.fsm" /maintenance 
nogui_disablemsg_runscript /scriptpath C:\myscript.txt /myparam "resetmodel(); runspeed(10000); go();"
· 4
5 |100000

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

Sebastien avatar image Sebastien commented ·

Thank you @Phil BoBo.

This works, except for passing parameters with strings like print("It works") or Table("Table_name")["col"]["row"] = 1. I could have mentionned that I wanted something like that earlier, sorry.

I tried playing with "word" and 'word' but could not make it work either.

I also tried escaping the "".


0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Sebastien commented ·

FlexSim's parsing of commandline parameters doesn't handle quotation mark characters within the string.

To account for that, you could use a different character, such as a single quote, and then replace it before calling executestring():

executestring(commandlineparam("myparam").as(string).replace("'", "\"", 1));
"C:\Program Files\FlexSim 2016\program\flexsim.exe" 
"C:\Users\username\Documents\Flexsim 16 Projects\test.fsm" /maintenance 
nogui_disablemsg_runscript /scriptpath C:\myscript.txt /myparam "Table('Table_name')['col']['row'] = 1; resetmodel(); runspeed(10000); go();"
0 Likes 0 ·
Sebastien avatar image Sebastien Phil BoBo ♦♦ commented ·
Wonderful ! Thank you @Phil BoBo !

It works beautifully.


0 Likes 0 ·
Show more comments