Reputation:
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:
open folder > .\project
, the function is in .\project\functions\dymIO\instantiateDymola.py
, then the Dymola working directory at startup is set at .\project
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
Upvotes: 0
Views: 86
Reputation: 12507
I don't know exactly what is happening with Python at the moment, but I can answer what happens inside Dymola:
.\Documents\Dymola
exists.DYMOLAWORKDIRECTORY
is not set it is set to .\Documents\Dymola
.\Documents\Dymola
- otherwise it keeps the current directory. This allows you to make a short-cut "Start Dymola Here!"But I don't know why the Python-interface changes current directory to .\project
, and if you could change current directory in Python.
Upvotes: 1