How to add load libraries, change directory, etc. on startup?

后端 未结 5 1849
遥遥无期
遥遥无期 2020-12-21 17:53

Is there a way to automatically load libraries, change to a certain working directory, etc. when launching Dymola?

5条回答
  •  天涯浪人
    2020-12-21 18:09

    This method has been tested for Dymola 2017FD01. Prior versions used a different method via a setup.mos script that is no longer available. As of this posting, there is no option to perform this actions via the Dymola GUI.

    It can be easily accomplished via a .mos file with the steps shown below:

    1. Create a .mos file in a location that makes sense. For example, C:\Users\USERNAME\Documents\Dymola\startup.mos
    2. Add the actions desired to .mos file. For example, to load a library add openModel("C:\\Users\\USERNAME\\Documents\\ModelicaLibrary\\package.mo");
    3. Dymola always puts its auto-generated files in the current working directory. It's often a good idea to have that location be the same location so there is no need to hunt down the location of output files. Therefore, at the end of the .mos file change the current directory: cd("C:\\Users\\USERNAME\\Documents\\Dymola");
    4. If no shortcut exists to the Dymola.exe file, then create one.
    5. Right click the shortcut and go to Properties. Under Shortcut>Target append "C:\Users\USERNAME\Documents\Dymola\startup.mos"at the end. The contents of that cell should now look something like this: "C:\Program Files (x86)\Dymola 2017 FD01\bin64\Dymola.exe" "C:\Users\vmg\Documents\Dymola\startup.mos"
    6. That's it. When Dymola is launched from that shortcut the actions specified in the .mos file should be carried out.

提交回复
热议问题