@@ -788,7 +788,7 @@ def sendExpression(self, command, parsed=True):
788788
789789
790790class ModelicaSystem (object ):
791- def __init__ (self , fileName = None , modelName = None , lmodel = [], useCorba = False , commandLineOptions = None , variableFilter = None , verbose = True ): # 1
791+ def __init__ (self , fileName = None , modelName = None , lmodel = [], useCorba = False , commandLineOptions = None , variableFilter = None , customBuildDirectory = None , verbose = True ): # 1
792792 """
793793 "constructor"
794794 It initializes to load file and build a model, generating object, exe, xml, mat, and json files. etc. It can be called :
@@ -856,7 +856,7 @@ def __init__(self, fileName=None, modelName=None, lmodel=[], useCorba=False, com
856856 self .getconn .sendExpression ("setCommandLineOptions(\" --linearizationDumpLanguage=python\" )" )
857857 self .getconn .sendExpression ("setCommandLineOptions(\" --generateSymbolicLinearization\" )" )
858858
859- self .setTempDirectory ()
859+ self .setTempDirectory (customBuildDirectory )
860860
861861 if fileName is not None :
862862 self .loadFile (verbose )
@@ -910,11 +910,16 @@ def loadLibrary(self, verbose):
910910 if verbose or not result :
911911 print (self .requestApi ('getErrorString' ))
912912
913- def setTempDirectory (self ):
913+ def setTempDirectory (self , customBuildDirectory ):
914914 # create a unique temp directory for each session and build the model in that directory
915- self .tempdir = tempfile .mkdtemp ()
916- if not os .path .exists (self .tempdir ):
917- return print (self .tempdir , " cannot be created" )
915+ if customBuildDirectory is not None :
916+ if not os .path .exists (customBuildDirectory ):
917+ print (customBuildDirectory , " does not exist" )
918+ self .tempdir = customBuildDirectory
919+ else :
920+ self .tempdir = tempfile .mkdtemp ()
921+ if not os .path .exists (self .tempdir ):
922+ print (self .tempdir , " cannot be created" )
918923
919924 exp = "" .join (["cd(" ,"\" " ,self .tempdir ,"\" " ,")" ]).replace ("\\ " ,"/" )
920925 self .getconn .sendExpression (exp )
0 commit comments