@@ -241,7 +241,7 @@ def __delete__(self, index_or_name):
241241 Args:
242242 index_or_name (str or int): Name of the index of model
243243 '''
244- if isinstance (index_or_name , str ):
244+ if isinstance (index_or_name , str ) and index_or_name in self . clientModelDct :
245245 assert index_or_name in list (self .clientModelDct )
246246 self .clientModelDct .pop (index_or_name )
247247 if len (self .clientModelDct ) > 0 :
@@ -252,8 +252,7 @@ def __delete__(self, index_or_name):
252252 if isinstance (index_or_name , int ):
253253 assert index_or_name <= len (self .clientModelDct )
254254 modelLs = connectionGlobals .client .service .get_model_list ()
255-
256- if modelLs :
255+ if modelLs and (modelLs .name [index_or_name ] in self .clientModelDct ):
257256 self .clientModelDct .pop (modelLs .name [index_or_name ])
258257 if len (self .clientModelDct ) > 0 :
259258 model_key = list (self .clientModelDct )[- 1 ]
@@ -327,6 +326,7 @@ def openFile(model_path):
327326 assert os .path .exists (model_path )
328327
329328 file_name = os .path .basename (model_path )
329+ connectToServer ()
330330 connectionGlobals .client .service .open_model (model_path )
331331
332332 return Model (False , file_name )
@@ -341,6 +341,8 @@ def closeModel(index_or_name, save_changes = False):
341341 index_or_name : Model Index or Name to be Close
342342 save_changes (bool): Enable/Disable Save Changes Option
343343 '''
344+
345+ connectToServer ()
344346 if isinstance (index_or_name , int ):
345347 Model .__delete__ (Model , index_or_name )
346348 connectionGlobals .client .service .close_model (index_or_name , save_changes )
@@ -357,7 +359,7 @@ def closeModel(index_or_name, save_changes = False):
357359 except :
358360 print ('Model did NOT close properly.' )
359361 else :
360- print ('\n INFO: Model "' + modelLs + '" is not opened.' )
362+ print ('\n INFO: Model "' + index_or_name + '" is not opened.' )
361363 else :
362364 assert False , 'Parameter index_or_name must be int or string.'
363365
0 commit comments