christiankral
christiankral

Reputation: 403

How to automatically create conversion script in Dymola

In https://trac.modelica.org/Modelica/ticket/2229#comment:2 it is mentioned that Dymola has the capability to automatically update a conversion script when changes are applied to a library. I was searching the Dymola manuals but could not find any actual guidelines how to apply this feature.

However, I could find some settings in the options, but I cannot force Dymola to create / update a conversion script.

enter image description here

Does anyone have some guidelines on how to enable the feature of automatically creating a conversion script?

Upvotes: 5

Views: 301

Answers (1)

marco
marco

Reputation: 6645

Generate commands for conversion

There are three advanced variables for that, namely:

Integer Advanced.ActivateSmartDelete = 3 "Updates other classes when deleting class/component [0 - no, 1 - ask, 2 yes (if possible)]";
Integer Advanced.ActivateSmartRename = 3 "Updates other classes when renaming component [0 - no, 1 - ask, 2 yes, 3 - also script]";
Integer Advanced.ActivateSmartRenameClass = 3 "Updates other classes when renaming class [0 - no, 1 - ask, 2 yes, 3 - also script]";

As the comments indicate, setting these variables on 3 (using the Dymola Command window or, in newer Dymola versions, the options which can be seen in your screenshot) results in automatically created conversion commands.

Dymola will write the conversion commands to the model annotation of your library. They will look something like this:

  from(
    version="3.2.3",
    to="Intermediate",
    change(item=convertClass("Modelica.Blocks.Continuous.PID", "Modelica.Blocks.Continuous.PID_Controller"),
           item=convertClass("Modelica.Blocks.Continuous.FirstOrder", "Modelica.Blocks.Continuous.PT1")))

Export commands to a file

Before Dymola 2022x

You have to convert the commands a little, if you want to have the conversion script in a separate file (instead of the package.mo of your library).

In a script the above commands would look as follows:

convertClear()
convertClass("Modelica.Blocks.Continuous.PID", "Modelica.Blocks.Continuous.PID_Controller"),
convertClass("Modelica.Blocks.Continuous.FirstOrder", "Modelica.Blocks.Continuous.PT1")

so the same commands, but without item= and trailing ,.

With Dymola 2022x

Dymola 2022x can export the commands to a file.

  • Open the Attributes dialog of your library from the package browser
  • Use the button Convert from Pre-Release... in the Version tab

Version tab in package attributes in Dymola

Dymola will then remove the previously generated commands from the library annotation and copy them in the correct format to the specified file. Note that Dymola will also update the version number of the library and adjust the from command. If this is not desired, change it back.

Upvotes: 6

Related Questions