salome_initial=0
sg = salome_iapp_init(embedded)
orb, lcc, naming_service, cm = salome_kernel_init()
- myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init(theStudyId)
+ myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init()
pass
pass
except RuntimeError, inst:
salome_study_ID = -1
-def getActiveStudy(theStudyId=0):
+def getActiveStudy():
global salome_study_ID
if verbose(): print "getActiveStudy"
salome_study_ID = salome_iapp.sg.getActiveStudyId()
else:
if verbose(): print "---outside gui"
- if theStudyId:
- aStudy=myStudyManager.GetStudyByID(theStudyId)
- if aStudy:
- if verbose(): print "connection to existing study ", theStudyId
- salome_study_ID = theStudyId
if salome_study_ID == -1:
+ 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 theStudyId:
+ #aStudy=myStudyManager.GetStudyByID(theStudyId)
+ #if aStudy:
+ #if verbose(): print "connection to existing study ", theStudyId
+ #salome_study_ID = theStudyId
if verbose(): print"--- Study Id ", salome_study_ID
return salome_study_ID
aStudyName = "noName"
nameAlreadyInUse = 1
listOfOpenStudies = myStudyManager.GetOpenStudies()
+ if len(listOfOpenStudies) != 0:
+ raise ValueError("There is already an opened study: %s" % listOfOpenStudies[0])
print listOfOpenStudies
while nameAlreadyInUse:
aStudyName = "extStudy_%d"%i
salome_study_initial = 1
-def salome_study_init(theStudyId=0):
+def salome_study_init():
"""
Performs only once study creation or connection.
optional argument : theStudyId
if verbose(): print "studyManager found"
# get active study Id, ref and name
- myStudyId = getActiveStudy(theStudyId)
+ myStudyId = getActiveStudy()
if verbose(): print "myStudyId",myStudyId
myStudy = myStudyManager.GetStudyByID(myStudyId)
myStudyName = myStudy._get_Name()