From 4f740c1f4ed62cdbbee0f81a48de7b33337f951a Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Sat, 12 Apr 2014 18:20:27 +0200 Subject: [PATCH] control the presence of active studies in Python salome.salome_init() --- src/KERNEL_PY/salome_study.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index 5e01b758c..29ba67d03 100755 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -285,7 +285,14 @@ def getActiveStudy(theStudyId=0): if verbose(): print "connection to existing study ", theStudyId salome_study_ID = theStudyId if salome_study_ID == -1: - salome_study_ID = createNewStudy() + listOpenStudies = myStudyManager.GetOpenStudies() + if len(listOpenStudies) == 0: + salome_study_ID = createNewStudy() + else: + s = myStudyManager.GetStudyByName(listOpenStudies[0]) + salome_study_ID = s._get_StudyId() + else: + pass if verbose(): print"--- Study Id ", salome_study_ID return salome_study_ID -- 2.39.2