Skip to content

Commit 7746aff

Browse files
committed
Allow passing multiple dependent libraries to ModelicaSystem
Fixes #63
1 parent 2129c2b commit 7746aff

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

OMPython/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def __init__(self, name, start, changable, variability, description, causality,
595595

596596

597597
class ModelicaSystem(object):
598-
def __init__(self, fileName=None, modelName=None, lmodel=None, useCorba=False): # 1
598+
def __init__(self, fileName=None, modelName=None, lmodel=[], useCorba=False): # 1
599599
"""
600600
"constructor"
601601
It initializes to load file and build a model, generating object, exe, xml, mat, and json files. etc. It can be called :
@@ -606,7 +606,7 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, useCorba=False):
606606
ex: myModel = ModelicaSystem("ModelicaModel.mo", "modelName")
607607
"""
608608

609-
if fileName is None and modelName is None and lmodel is None: # all None
609+
if fileName is None and modelName is None and not lmodel: # all None
610610
if useCorba:
611611
self.getconn = OMCSession()
612612
else:
@@ -697,13 +697,13 @@ def __loadingModel(self, fName, mName, lmodel):
697697
return
698698

699699
# load Modelica standard libraries if needed
700-
if lmodel is not None:
701-
loadmodelError = ''
702-
loadModelResult = self.requestApi("loadModel", lmodel)
703-
loadmodelError = self.requestApi('getErrorString')
704-
if loadmodelError:
705-
print(loadmodelError)
706-
return
700+
for element in lmodel:
701+
if element is not None:
702+
loadmodelError = ''
703+
loadModelResult = self.requestApi("loadModel", element)
704+
loadmodelError = self.requestApi('getErrorString')
705+
if loadmodelError:
706+
print(loadmodelError)
707707

708708
# build model
709709
# buildModelError = ''

0 commit comments

Comments
 (0)