X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FKERNEL_PY%2Fsalome_study.py;h=c8fab2542b9bcece546963276dd4be76e91c5c91;hb=c249f953254adaf596bf69169ee42aab1310fa54;hp=5626aecdf8b13c3722364f03b1a79d6014d43d8e;hpb=dc4b16b9dd53dd42139fd22ef26556861db58989;p=modules%2Fkernel.git diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py old mode 100755 new mode 100644 index 5626aecdf..c8fab2542 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -271,11 +271,48 @@ def FindFileInDataDir(filename): #-------------------------------------------------------------------------- def openStudy(theStudyPath): - print("openStudy") + if verbose(): print("openStudy (begin)") global myStudy, myStudyName myStudy.Open(theStudyPath) myStudyName = myStudy._get_Name() - print(theStudyPath, myStudy._get_Name()) + if verbose(): print("openStudy (end):", theStudyPath, myStudy._get_Name()) + + #-------------------------------------------------------------------------- + +def salome_study_init_without_session(theStudyPath=None): + """ + Performs only once study creation or connection. + optional argument : theStudyPath + None : attach to the currently active single study; + create new empty study if there is active study + (str) : open study with the given file name + """ + global myStudy, myStudyName + global orb, lcc, naming_service, cm + + if verbose(): print("theStudyPath:", theStudyPath) + if not myStudy: + import CORBA + orb = CORBA.ORB_init(['']) + + # get Study reference + if verbose(): print("looking for study...") + import KernelDS + myStudy = KernelDS.myStudy() + if verbose(): print("Study found") + pass + + import types + if theStudyPath and isinstance(theStudyPath, (str, bytes)): + if isinstance(theStudyPath, bytes): + theStudyPath = str(theStudyPath, 'UTF8') + openStudy(theStudyPath) + else: + myStudy.Init() + + myStudyName = myStudy._get_Name() + + return myStudy, myStudyName #-------------------------------------------------------------------------- @@ -292,7 +329,7 @@ def salome_study_init(theStudyPath=None): if verbose(): print("theStudyPath:", theStudyPath) if not myStudy: - orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init() + orb, lcc, naming_service, cm, _, _, _ = salome_kernel.salome_kernel_init() # get Study reference if verbose(): print("looking for study...") @@ -306,7 +343,13 @@ def salome_study_init(theStudyPath=None): if isinstance(theStudyPath, bytes): theStudyPath = str(theStudyPath, 'UTF8') openStudy(theStudyPath) + else: + myStudy.Init() myStudyName = myStudy._get_Name() return myStudy, myStudyName + +def salome_study_close(): + global myStudy, myStudyName + myStudy, myStudyName = None, None