From: vsr Date: Tue, 16 Feb 2010 09:20:56 +0000 (+0000) Subject: 0020702: [CEA] Problem with Segment function of SMESH module X-Git-Tag: V5_1_4a1~83 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97a2f52e50af3a3052b28c9a2f941f56c42c714e;p=modules%2Fsmesh.git 0020702: [CEA] Problem with Segment function of SMESH module 0020701: EDF SMESH : GetName Method of smeshDC.py Additional fix --- diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index 606b782ce..66afda3a7 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -390,18 +390,36 @@ def IsEqual(val1, val2, tol=PrecisionConfusion): return True return False +NO_NAME = "NoName" + ## Gets object name def GetName(obj): - if isinstance(obj, SALOMEDS._objref_SObject): - return obj.GetName() - ior = salome.orb.object_to_string(obj) - studies = salome.myStudyManager.GetOpenStudies() - for sname in studies: - s = salome.myStudyManager.GetStudyByName(sname) - if not s: continue - sobj = s.FindObjectIOR(ior) - if not sobj: continue - return sobj.GetName() + if obj: + # object not null + if isinstance(obj, SALOMEDS._objref_SObject): + # study object + return obj.GetName() + ior = salome.orb.object_to_string(obj) + if ior: + # CORBA object + studies = salome.myStudyManager.GetOpenStudies() + for sname in studies: + s = salome.myStudyManager.GetStudyByName(sname) + if not s: continue + sobj = s.FindObjectIOR(ior) + if not sobj: continue + return sobj.GetName() + if hasattr(obj, "GetName"): + # unknown CORBA object, having GetName() method + return obj.GetName() + else: + # unknown CORBA object, no GetName() method + return NO_NAME + pass + if hasattr(obj, "GetName"): + # unknown non-CORBA object, having GetName() method + return obj.GetName() + pass raise RuntimeError, "Null or invalid object" ## Prints error message if a hypothesis was not assigned.