File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1144,21 +1144,28 @@ def simulate(
11441144 def plot (
11451145 self ,
11461146 plotdata : str ,
1147- resultfile : Optional [str ] = None ,
1147+ resultfile : Optional [str | os . PathLike ] = None ,
11481148 ) -> None :
11491149 """
1150- Plot via OMC.
1150+ Plot a variable using OMC; this will work for local OMC usage only (OMCProcessLocal) .
11511151 """
11521152
1153- if resultfile is None :
1154- # default result file generated by OM
1155- plot_result_file = self .getWorkDirectory () / f"{ self ._model_name } _res.mat"
1156- elif os .path .exists (resultfile ):
1153+ if not isinstance (self ._getconn .omc_process , OMCProcessLocal ):
1154+ raise ModelicaSystemError ("Plot is using the OMC plot functionality; "
1155+ "thus, it is only working if OMC is running locally!" )
1156+
1157+ plot_result_file = None
1158+ if resultfile is not None :
11571159 plot_result_file = pathlib .Path (resultfile )
1160+ elif self ._result_file is not None :
1161+ plot_result_file = pathlib .Path (self ._result_file )
11581162 else :
11591163 ModelicaSystemError ("No resultfile available - either run simulate() before plotting "
11601164 "or provide a result file!" )
11611165
1166+ if not plot_result_file .is_file ():
1167+ ModelicaSystemError (f"Provided resultfile { repr (plot_result_file .as_posix ())} does not exists!" )
1168+
11621169 expr = f'plot({ plotdata } , fileName="{ plot_result_file .as_posix ()} ")'
11631170
11641171 self .sendExpression (expr = expr )
You can’t perform that action at this time.
0 commit comments