Dymola tips and tricks series (V)Jesse Gohl
Have you been working with Dymola for a while but still feel that you are not using it as effectively as you could be? In this series of posts, we’ll share tips and tricks that we have picked up along the way.
Part V: Saving packages in Dymola
What options do we have?
One of the questions about Dymola usage that I get frequently is related to the option of saving packages as either single files or as directories (see Fig. 1). When you are saving a package Dymola will ask you if you want to save the contents in a single file.
Unchecking this option saves the package as a directory with its contents as individual files (and additional directories).
Saving a package as a single file is convenient when you want to share the file with others, but it’s a pain when using version control.
Fig. 1 Setup for saving packages
Change the default option
The default when you install Dymola is that this option is checked. The question I’m then asked is… can I change this to be unchecked by default? The answer is yes, although it’s definitely not obvious how. It turns out this setting is saved in the dymodraw.ini file (see Fig. 2) in the insert folder of the Dymola installation (obvious huh!).
This file contains a number of options for customizing the Dymola user interface itself, for example menus and diagram drawing defaults but the one I’m concerned with is Dymola5StoreOnOneFile. By setting this value to 0, the checkbox in the above figure will be unchecked by default. This is probably the first thing I change when I install Dymola.
Fig. 2 A glimpse of dymodraw.ini – change the default saving in this file
Change package saving from file to directory (or vice versa)
Of course we’ve all had this happen, we get a package from someone that was saved as a single file, but now want to change it to a directory, so that we can version control it (or vice versa for that matter).
How should we do this? There are three approaches to do this “Edit Attributes”, “Save as” or “Rename”. Starting with the easiest first:
Edit Attributes approach
Dymola includes a menu option for modifying the attributes it associates with various Modelica classes. If you have a class (e.g. a model, record, function, package, etc.) selected in the Package Browser, you can simply choose “Edit” → “Edit Attributes…”. Note that in some older versions of Dymola this was named “View Attributes…” but it has the same function.
From this dialog box, you can control most attributes associated with the particular Modelica class. You can even change the class type. For example, if you mistakenly created a new model when you wanted a package you can change that here too.
Fig. 3 Edit the package attributes – the easiest way
In the figure above (Fig. 3), I changed my default Unnamed model to a package. After I did that and closed and reopened the dialog box, Dymola then enables the “Store as one file” check box. Now all I need to do is uncheck this and Dymola will save my package as a directory instead of a single file.
**My apologies to the Dymola team for not pointing out this feature in my original blog post. This seems to be a case of teaching this “old dog” new tricks!
If the package you want to change is a top level package you can simply use “Save as” from the File menu. Be sure the active package in the current window is the top level package.
Dymola might warn you that you are saving without duplicating, but this is normal. It just warns you that you didn’t explicitly tell Dymola to duplicate the package.
If you are saving the package to a directory structure, Dymola will also ask for each sub-package if you want it to also be a directory or single file (see Fig. 4).
Fig. 4 Save the package – choose the convenient way
If you want all packages to be directories, you can simply choose “Directories – No Questions”. You can also check the location of the package (and for any Modelica class) on the file system from the information layer.
Dymola reports the location in the Filename shown at the bottom of the window in the modeling tab (see Fig. 5).
Fig. 5 Check the location for the saving in the bottom of the modeling tab
If the package you want to convert to or from a directory structure is not a top level package, you will need to use “Rename”. Right click on the package in the Package Browser and choose “Rename…”. Temporarily name the package something different. I usually just append an underscore (_) character (see Fig. 6).
Fig. 6 – Rename the package
Finally use “Rename…” again to name it back to the original name, but this time either check or uncheck the box to “Save contents of package in one file” (see Fig. 7).
Fig. 7 Rename the package back to original and set right the check-box for saving in one file
Do you have tips to share or an issue you would like addressed? Please post a comment so we can spread the knowledge!