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

OMC Scripting

OMC Scripting

I tried this command

getParameterValue("BouncingBall","e")

on the BouncingBall model within share\doc\omc\testmodels:

model BouncingBall
  parameter Real e=0.7 "coefficient of restitution";
...


and I received this error message:

[<interactive>:1:1-1:0:writable] Error: Class getParameterValue not found in scope <global scope> (looking for a function or record).

According to this web page (https://build.openmodelica.org/Document … alue.html), the getParameterValue function should work. What did I miss? Any help would be greatly appreciated. Thanks.

BTW, loadModel(Modelica) and loadFile(getInstallationDirectoryPath()+"/share/doc/omc/testmodels/BouncingBall.mo") both returned true beforehand.

Best regards,
Axel

Edited by: axelr - Dec-17-15 06:00:52

Re: OMC Scripting

The doc is like this:

Code:


function getParameterValue
  input TypeName class_;
  input String parameterName;
  output String parameterValue;
end getParameterValue;

Which means you need to call it like this:

Code:


getParameterValue(BouncingBall,"e"); // no quotes for the first argument which is of TypeName

For more examples of the API you can have a look here:
https://github.com/OpenModelica/OpenMod … active-API
Begin with files interactive_*.mos

Cheers,
Adrian Pop/

Edited by: adrpo - Dec-17-15 08:33:24

Re: OMC Scripting

BTW, what do you want to do with the API?

Re: OMC Scripting

Thanks for your help. I want to improve the SysML-Modelica transformation and make it work between OpenModelica 1.9.3 and MagicDraw 18.2 (https://github.com/SysMLModelicaIntegra … modelica).

Edited by: axelr - Dec-17-15 14:11:45
There are 0 guests and 0 other users also viewing this topic