salome_initial=0
sg = salome_iapp_init(embedded)
orb, lcc, naming_service, cm = salome_kernel_init()
- myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init()
+ myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init(theStudyId)
pass
pass
except RuntimeError, inst:
"""
raise
+def salome_close():
+ global salome_initial
+ salome_initial=1
+ salome_iapp_close()
+ salome_kernel_close()
+ salome_study_close()
+ pass
+
+
#to expose all objects to pydoc
__all__=dir()
salome_study_ID = -1
-def getActiveStudy():
+def getActiveStudy(theStudyId=0):
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():
+def salome_study_init(theStudyId=0):
"""
Performs only once study creation or connection.
optional argument : theStudyId
if verbose(): print "studyManager found"
# get active study Id, ref and name
- myStudyId = getActiveStudy()
+ myStudyId = getActiveStudy(theStudyId)
if verbose(): print "myStudyId",myStudyId
myStudy = myStudyManager.GetStudyByID(myStudyId)
myStudyName = myStudy._get_Name()
return myStudyManager, myStudyId, myStudy, myStudyName
+def salome_study_close():
+ global salome_study_initial, salome_study_ID
+ salome_study_initial=1
+ salome_study_ID=-1
+ pass