Search code examples
pythonmodelicadymola

How to set Advanced.EnableCodeExport flag in Dymola through Python?


In a workflow, I am trying to automate the process of fmu generation from Dymola using the Python functions in dymola.egg. I was able to achieve this using following function.

dymola.translateModelFMU(model, True, 
                              fmiVersion ="2",
                              fmiType ="all");

However this generates fmus without binary export (generates license dependent fmus).
I have floating license for binary export available, therefore I would like to checkout and return the binary export license through the script. In order to achieve this, is there a way to set Advanced.EnableCodeExport = True through Python?
Is there any other way (other libraries) to achieve this? The goal is to checkout the floating binary export license as needed. I guess with dymola.close() both Dymola and binary export licenses will be returned for others to use.


Solution

  • dymola.ExecuteCommand() exists as a fallback solution for everything that can be set from the commands window in Dymola, but is not available in the python interface.

    Hence you can set the flag with:

    dymola.ExecuteCommand("Advanced.EnableCodeExport=true")
    

    Note that true must be written lower case here (as Modelica and Dymola do, in contrast to python).