File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1135,21 +1135,28 @@ def simulate(
11351135 def plot (
11361136 self ,
11371137 plotdata : str ,
1138- resultfile : Optional [str ] = None ,
1138+ resultfile : Optional [str | os . PathLike ] = None ,
11391139 ) -> None :
11401140 """
1141- Plot via OMC.
1141+ Plot a variable using OMC; this will work for local OMC usage only (OMCProcessLocal) .
11421142 """
11431143
1144- if resultfile is None :
1145- # default result file generated by OM
1146- plot_result_file = self .getWorkDirectory () / f"{ self ._model_name } _res.mat"
1147- elif os .path .exists (resultfile ):
1144+ if not isinstance (self ._getconn .omc_process , OMCProcessLocal ):
1145+ raise ModelicaSystemError ("Plot is using the OMC plot functionality; "
1146+ "thus, it is only working if OMC is running locally!" )
1147+
1148+ plot_result_file = None
1149+ if resultfile is not None :
11481150 plot_result_file = pathlib .Path (resultfile )
1151+ elif self ._result_file is not None :
1152+ plot_result_file = pathlib .Path (self ._result_file )
11491153 else :
11501154 ModelicaSystemError ("No resultfile available - either run simulate() before plotting "
11511155 "or provide a result file!" )
11521156
1157+ if not plot_result_file .is_file ():
1158+ ModelicaSystemError (f"Provided resultfile { repr (plot_result_file .as_posix ())} does not exists!" )
1159+
11531160 expr = f'plot({ plotdata } , fileName="{ plot_result_file .as_posix ()} ")'
11541161
11551162 self .sendExpression (expr = expr )
You can’t perform that action at this time.
0 commit comments