You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OMPython using getParameterValue with sendExpression in a python script #54
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 "", line 1, in
File "/home/user/.local/lib/python2.7/site-packages/OMPython/init.py", line 484, in sendExpression
answer = OMTypedParser.parseString(result)
File "/home/user/.local/lib/python2.7/site-packages/OMPython/OMTypedParser.py", line 109, in parseString
return omcGrammar.parseString(string)[0]
File "/home/user/.local/lib/python2.7/site-packages/pyparsing.py", line 1632, in parseString
raise exc
pyparsing.ParseException: Expected {quoted string, starting with " ending with " | Combine:({["-"] {"0" | W:(1234...,0123...)} [{"." W:(0123...)}] [{W:(eE) W:(0123...,0123...)}]}) | Forward: ... | Group:({Suppress:("{") [Forward: ... [, Forward: ...]...] Suppress:("}")}) | Group:({Suppress:("(") [Forward: ... [, Forward: ...]...] Suppress:(")")}) | {Suppress:("SOME") Suppress:("(") Forward: ... Suppress:(")")} | "true" | "false" | {"NONE" Suppress:("(") Suppress:(")")} | Combine:(Forward: ...)} (at char 1), (line:2, col:1)
Am I doing something wrong or is my installation corrupted? Because any other command from the scripting API works just fine.
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).
Activity
thorade commentedon Nov 22, 2017
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/
sjoelund commentedon Nov 22, 2017
You can also try with
parsed=Falseto 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).