@@ -697,8 +697,8 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOption
697697 # set default command Line Options for linearization as
698698 # linearize() will use the simulation executable and runtime
699699 # flag -l to perform linearization
700- self .sendExpression ( ' setCommandLineOptions("--linearizationDumpLanguage=python")' )
701- self .sendExpression ( ' setCommandLineOptions("--generateSymbolicLinearization")' )
700+ self .setCommandLineOptions ("--linearizationDumpLanguage=python" )
701+ self .setCommandLineOptions ("--generateSymbolicLinearization" )
702702
703703 self .setTempDirectory (customBuildDirectory )
704704
@@ -714,10 +714,11 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOption
714714
715715 def setCommandLineOptions (self , commandLineOptions : str ):
716716 # set commandLineOptions if provided by users
717- if commandLineOptions is not None :
718- exp = f'setCommandLineOptions("{ commandLineOptions } ")'
719- if not self .sendExpression (exp ):
720- self ._check_error ()
717+ if commandLineOptions is None :
718+ return
719+ exp = f'setCommandLineOptions("{ commandLineOptions } ")'
720+ if not self .sendExpression (exp ):
721+ self ._check_error ()
721722
722723 def loadFile (self ):
723724 # load file
@@ -1540,7 +1541,7 @@ def optimize(self): # 21
15401541 """
15411542 cName = self .modelName
15421543 properties = ',' .join (f"{ key } ={ val } " for key , val in self .optimizeOptions .items ())
1543- self .sendExpression ( ' setCommandLineOptions("-g=Optimica")' )
1544+ self .setCommandLineOptions ("-g=Optimica" )
15441545 optimizeResult = self .requestApi ('optimize' , cName , properties )
15451546 self ._check_error ()
15461547
0 commit comments