Search code examples
command-promptmodelicadymola

Execute dymola command from command prompt


Is there a way to pass Dymola a command from the Windows command prompt? I want to pass it commands like Simulate(), openModel etc.


Solution

  • Well, you could write a script file (.mos) file instead. if are really interested in opening model/simulating a model using a .bat file, then you could also create a .bat file to write a script(.mos) file and then run the script file. I can provide an example for the same.

    You could use the following line of code in a batch file and try running the same:

    SET var=%cd%
    cd %var%
    echo openModel("%var%\test_case.mo", true) > filename.txt
    echo simulateModel("test_case", method="dassl", resultFile="test_case") >> filename.txt
    copy "filename.txt" "script.txt"
    rename "script.txt" "script.mos"
    script.mos
    

    I am writing a script file (script.mos) first and then running the same. please note that I am referring to the current directory.

    I am not sure if I have answered your question exactly, please feel free to suggest on the same.