0
votes

I try to run python script, but i got error in line, where i used ModelicaSystem, but i don't understand how to fix the problem

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
model_path=omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
from OMPython import ModelicaSystem
mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
mod.buildModel()

Error:

Traceback (most recent call last):
  File "C:\Users\Aleksandr\Documents\OpenModelica\test.py", line 5, in <module>
    mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
  File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 720, in __init__
    self.__loadingModel()
  File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 760, in __loadingModel
    self.buildModel() 
  File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 770, in buildModel
    self.xmlparse()
  File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 815, in xmlparse
    ch = sv.getchildren()
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'

Process finished with exit code 1
1

1 Answers

1
votes

Note, this method was deprecated since 3.2, though only warned in 3.8:
Visit this link
https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren