From 31f02551b4346e45211f095a2135c61f46b0fcbd Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Tue, 9 Mar 2021 16:42:47 +0100 Subject: [PATCH] Allow to find an object ior in a study in sessionless mode Do not init the study in session-less mode --- src/KERNEL_PY/__init__.py | 1 + src/KERNEL_PY/salome_study.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 0d7603e05..ef18851c8 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -205,6 +205,7 @@ def salome_init_without_session(): poaManager = poa._get_the_POAManager() poaManager.activate() sg = SalomeOutsideGUI() + salome_study_init_without_session() def salome_init_with_session(path=None, embedded=False): """ diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index bf6a52986..0d1ba67da 100644 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -279,6 +279,35 @@ def openStudy(theStudyPath): #-------------------------------------------------------------------------- +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 + + myStudyName = myStudy._get_Name() + + return myStudy, myStudyName + + #-------------------------------------------------------------------------- + def salome_study_init(theStudyPath=None): """ Performs only once study creation or connection. -- 2.39.2