Conversion Scripts: Create One As You Develop Your Library

In my last blog post, Migration to Newer Library Versions, I looked at using conversion scripts to migrate your library to newer versions of other libraries used. But how are these conversion scripts created? In this blog post I’m going to go through an approach you can use to create your own conversion scripts while making changes to your library.

Creating Conversion Scripts with Dymola

Here at Claytex we use an in-house tool to create conversion scripts for our libraries. But there are 2 approaches using Dymola that you can use to build your own conversion scripts, depending whether you want to do this during or after library development.

I’m going to go through how to create conversion commands during library development in this post; but you can find out about the after development approach in section 16.1.3 ‘How to build a convert script‘ in the Dymola Full User Manual.

During Development

When you set the flags Advanced.ActivateSmartRenameClass and Advanced.ActivateSmartRename to 3, and then make name and location changes to your library, Dymola automatically generates conversion commands. The first flag relates to updating other classes when renaming a class and the second updating other classes when renaming components. When set to:

  • 0 Other classes are not updated.
  • 1 – The user is asked whether other classes should be updated.
  • 2 – Other classes are updated (default).
  • 3 – Other classes are updated and related conversion commands are generated.

Using the Dymola Flags to Create Conversion Scripts

I demonstrate creating conversion scripts during development with the flags in the video below. There is a summary of steps beneath.

  1. Prior to making any changes to your libraries, set the flags Advanced.ActivateSmartRenameClass=3 and Advanced.ActivateSmartRename=3 in the Dymola.
  2. Make changes to your library using the graphical user interface (GUI):
    • Rename a class, component or variable.
    • Move a class.
  3. When development is complete, you can move the conversion commands generated in the library annotation to a separate conversion script. Update the conversion annotation in the library to make use of this script.

I used Dymola 2022 and our VehicleDemos library in the video. The VehicleDemos library demonstrates the coupling of automotive libraries, as shown in these previous blog posts on coupling automotive libraries and modelling an electric bus.

Things to Consider

While these flags can help you to create your conversion scripts, there are a couple of things to keep in mind:

  • Using these flags will not create a conversion command if you delete a class, component or variable. So you will need to create these conversion commands manually if required.
  • When you apply and then undo a change, a conversion command will be added for both actions. So you’ll need to sanity check the conversion commands generated to remove these unnecessary commands.
  • If you swap to making changes in the Modelica text rather than the GUI then the conversion commands will not be automatically created.

Written by: Hannah Hammond-Scott – Modelica Project Leader

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2021 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?