Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

How can I use a converion script

How can I use a converion script

Consider following example

Code:


package myLib

package Archive
end Archive

package subPacakge
    model myModel
    end myModel;
end subPacakge;

annotation(version="1.0.0"
and myLib;

and a newer version of it

Code:


package myLib

package Archive
    model myModel
    end myModel;
end Archive

package subPacakge
    model myModel_v2
    end myModel_v2;
end subPacakge;

annotation(version="1.0.1",
conversion(from(version={"1.0.0"}, script="modelica://oldLib/Resources/convertingScript.mos")));
and myLib;

with mos script inside Resources

Code:


convertClass("oldLib.subPackage.model_v1",
             "oldLib.Arcihve.model_v1")

how can I convert a model/package using convert script in OMEdit, if my library was not in HOME/.openmodelica/library ?

Code:


package testPackage
    model testModel
        oldLib.subPackage.model_v1 model_v1;
    end testModel;

annotation(uses(oldLIb(version="1.0.0")));

I've tried running [code}OpenModelica.Scripting.convertPackageToLibrary(testPackage, oldLib, "1.0.1")

Code:


[1] 12:24:43 Translation Error
JSON expected value, got <EOF>...

[2] 12:24:43 Scripting Error
[C:/Users/~/AppData/Roaming/.openmodelica/libraries/index.json: 0:0-0:0]: The package index C:/Users/~/AppData/Roaming/.openmodelica/libraries/index.json could not be parsed.

What did i missed?

Edit: I got it working by pre-loading the testPackage whe OM is open. But this does not change the original source code of testPackage. If one want to "update" the source code of testPackage, than one have to make a new copy of testPackage with save_as

Edit 2: right-click on myModel on Library Browser and right click up update binding seems to solve my problem. But it will be awful if you have multiple models that need to be updated

Edited by: Arinomo23 - Apr-05-22 11:31:59
There are 0 guests and 0 other users also viewing this topic
You are here: