]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0020702: [CEA] Problem with Segment function of SMESH module
authorvsr <vsr@opencascade.com>
Tue, 16 Feb 2010 09:20:56 +0000 (09:20 +0000)
committervsr <vsr@opencascade.com>
Tue, 16 Feb 2010 09:20:56 +0000 (09:20 +0000)
0020701: EDF SMESH : GetName Method of smeshDC.py
Additional fix

src/SMESH_SWIG/smeshDC.py

index 606b782ceda9a70b755e5fec901eb3ef65a00384..66afda3a7cdce20a259c042ce2f0f7640510eced 100644 (file)
@@ -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.