I just noticed an odd behavior in Dymola 2022, and I wonder if and how can I take care of it from the Python interface.
Odd behavior, because I expect Dymola to consistently set the working directory at .\Documents\Dymola
at startup, unless told otherwise.
However, when I instantiate Dymola from its Python interface, at startup the working directory is set according to the setting Tools > Options > Settings > Save startup directory
as follows:
Do not save
- then when I instantiate Dymola, the current directory is set as the directory where the python environment is open. Possibly interesting here:- the directory where the python environment is open is not the directory where the function is located.
- Example: in VSCode
open folder > .\project
, the function is in.\project\functions\dymIO\instantiateDymola.py
, then the Dymola working directory at startup is set at.\project
- Example: in VSCode
- the directory where the python environment is open is not the directory where the function is located.
Save this directory > .\Documents\Dymola
- then the current directory is set reliably at.\Documents\Dymola
One solution/fix would be to set the working directory after Dymola is instantiated, I am aware of it.
My question is rather to get an understanding of what might be going on with this behavior, and if there is a possibility to take care of it right at startup rather than afterwards