Salome HOME
Merge Python 3 porting.
[modules/kernel.git] / doc / salome / examples / example5
1
2 #              create AttributeName     
3 #===========================================================
4 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeName")
5 if A == None :
6         raise  RuntimeError, "Can't create AttributeName attribute"
7 A = A._narrow(SALOMEDS.AttributeName)
8
9 if A == None :
10         raise  RuntimeError, "Can't create AttributeName attribute"
11 A.SetValue("AttributesTesting")
12
13 if A.Value() != "AttributesTesting":
14         print("Wrong  value of AttributeName")
15
16
17 #      save / restore study      
18 #=================================
19 str= os.getenv("TmpDir")
20 if str == None:
21         str = "/tmp"
22 file = str+"/test.hdf"
23
24 batchmode_geompy.myStudy.SaveAs(file)
25 openedStudy = batchmode_geompy.myStudy.Open(file);
26
27 if openedStudy == None:
28         raise  RuntimeError, "Can't open saved study!"
29
30
31 father = openedStudy.FindComponent("GEOM")
32 if father is None:
33          raise  RuntimeError, "Geom component is not found!  Wrong study is opened." 
34
35
36 #     find AttributeName
37 #======================================
38
39 res,A=father.FindAttribute("AttributeName")
40 if res == 0 or A == None:
41         raise  RuntimeError, "Error:  not found AttributeName"
42
43 A = A._narrow(SALOMEDS.AttributeName)
44
45 if A == None :
46         raise  RuntimeError, "Can't create AttributeName attribute"
47
48 if A.Value() != "AttributesTesting":
49         print("Wrong  value of AttributeName")
50