OMPython
OMPython copied to clipboard
OMPython using getParameterValue with sendExpression in a python script
I tried every command listed in the scripting API, everyone works except for getParameterValue:
when I type omc.sendExpression("setParameterValue(MyModel, param1, 2)") it replies: OK (I already loaded the MyModel model first using loadModel with sendExpression)
when I type omc.sendExpression("getParameterValue(MyModel, param1)") it should reply "2" but instead it gives me a huge error:
File "
Am I doing something wrong or is my installation corrupted? Because any other command from the scripting API works just fine.
Thank you.
From the error message it seems you are using Python 2 on Linux!? Corba Session or ZMQ session? What OMC version?
Could you also try the commands listed here? https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/ompython.html#import-as-library These also results in an error for me.
If you give the full script to reproduce your error then that script could be used for testing later.
And a minor sidenote: your text will be more readable if you mark the error messages as code: https://guides.github.com/features/mastering-markdown/
You can also try with parsed=False
to see what the raw string is. Usually this message appears when trying to parse an empty string (I think we should catch that and either return None or a better exception).