我刚刚注意到Dymola 2022中有一种奇怪的行为,我想知道是否以及如何通过Python接口来处理它。
奇怪的行为,因为我期望Dymola在启动时始终在.\Documents\Dymola上设置工作目录,除非另有说明。
但是,当我从Python接口实例化Dymola时,在启动时根据设置Tools > Options > Settings > Save startup directory设置工作目录,如下所示:
Do not save -然后当我实例化Dymola时,将当前目录设置为打开的目录。这里可能很有趣:- 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`Save this directory > .\Documents\Dymola -然后在.\Documents\Dymola上可靠地设置当前目录
一个解决方案/修复将是在实例化Dymola之后设置工作目录,我知道。
我的问题是了解这种行为可能会发生什么,以及是否有可能在启动时而不是事后处理好它。
发布于 2021-10-13 15:30:26
我不知道Python目前到底发生了什么,但我可以回答Dymola内部发生了什么:
从start菜单启动程序时,当前目录默认设置为程序的安装目录(在本例中是Dymola )。
.\Documents\Dymola存在。
DYMOLAWORKDIRECTORY没有设置,则当前目录与Dymola的安装目录相同,然后将当前目录设置为.\Documents\Dymola,否则它保留当前目录。这使您可以制作一个简短的“在这里启动Dymola!”
但我不知道为什么Python接口会将当前目录更改为.\project,以及是否可以更改Python中的当前目录。
https://stackoverflow.com/questions/69554573
复制相似问题