如何将自定义包添加到 Dymola/Modelica 中的启动路径? [英] How can I add a custom package to the startup path in Dymola/Modelica?

查看:29
本文介绍了如何将自定义包添加到 Dymola/Modelica 中的启动路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义包,我发现自己在 Dymola 模型中重复使用了该包,我想将此包放在一个公共目录中,该目录在我启动 Dymola 时会自动加载.我目前的策略是在加载我正在处理的模型时加载自定义包,然后保存总数.这并不优雅,因为自定义包的内容最终保存在我硬盘驱动器的多个位置,如果我更改其中之一,更改不会在任何地方反映出来.我想要一种更强大的方式来将此自定义包分发到我的所有模型.有没有办法告诉 Dymola 每次都自动加载我的自定义打包?

I have a custom package that I find myself reusing repeatedly in Dymola models, and I'd like to put this package in a common directory that is automatically loaded whenever I start Dymola. My current strategy is to load the custom package when a model I'm working on is loaded and then save total. This is not elegant because the contents of the custom package end up saved in multiple locations across my hard drive, and if I change one of them, the changes are not reflected everywhere. I would like a more robust way of distributing this custom package to all of my models. Is there a way to tell Dymola to automatically load my custom packaged every time?

推荐答案

诀窍是在 c:/Users/USERNAME/AppData/Roaming/Dynasim 中的 settings.mos 中添加以下几行:

The trick is to add the following lines to settings.mos in c:/Users/USERNAME/AppData/Roaming/Dynasim:

Utilities.setenv("MODELICAPATH", "C:\Users\USERNAME\Documents\Dymola");
openModel("c:\Users\USERNAME\Documents\Dymola\UserDefined\package.mo")

第一行将目录添加到 Dymola 用于搜索模型第一次运行之前尚未加载的包的路径中,第二行加载指定的包.这两个命令可能有些多余,但我同时执行这两个命令,因为除了加载 UserDefined 包之外,我还想确保我的自定义包在路径上.

The first line adds the directory to the path that Dymola uses to search for packages that have not been loaded prior to the first run of a model, and the second line loads the specified package. These two commands may be somewhat redundant, but I am doing both because I want to make sure my custom packages are on the path in addition to loading the UserDefined package.

这篇关于如何将自定义包添加到 Dymola/Modelica 中的启动路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆