I tried to exchange my Modelica model with one of my colleagues but ran into difficulties regarding paths to CSV-Files.
When I create the FMU the paths to some of the CSV files are set and point to folders on my computer. For example C:/Users/Me/file.csv. This obviously doesn't work for my colleague.
How can I export my Modelica model (Dymola) in such a way that the paths are set relative to the user?
The most common way is to use the loadResource()
function provided with the Modelica Standard Library (MSL) at Modelica.Utilities.Files.loadResource
to specify the path to the file. This is usually done using a Modelica URI, which could look like this:
filename=Modelica.Utilities.Files.loadResource("modelica://myLib/Resources/Data/file.csv")
This specifies a path relative to the libraries root path. Usually data files are stored in the Resources folder within the library.
This comes with the advantage, that when creating the FMU in Dymola, you can check the flag "Copy resources to FMU", which will embed the file in the FMU directly if checked. If unchecked, the file will be looked for in the specified directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With