Salome HOME
[PY3] Fix m4 macro for python 3
[modules/kernel.git] / doc / salome / examples / example12
1
2 #--------------------------------------------------------------------------
3 #              create    AttributeTextColor
4 #===========================================================
5 import SALOMEDS_Attributes_idl
6 color = SALOMEDS_Attributes_idl._0_SALOMEDS.Color(234,345,231)
7
8 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeTextColor")
9
10 if A == None :
11         raise  RuntimeError, "Can't create AttributeTextColor attribute"
12 A = A._narrow(SALOMEDS.AttributeTextColor)
13
14 if A == None :
15         raise  RuntimeError, "Can't create AttributeTextColor attribute"
16
17 A.SetTextColor(color)
18
19 c = A.TextColor();
20
21 if c.R != 234 or c.G != 345 or c.B != 231:
22         print("Error: wrong value of AttributeTextColor")
23
24 #      save / restore study      
25 #============================================================
26 str= os.getenv("TmpDir")
27 if str == None:
28         str = "/tmp"
29 file = str+"/test.hdf"
30
31 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
32 openedStudy = batchmode_geompy.myStudyManager.Open(file);
33
34 if openedStudy == None:
35         raise  RuntimeError, "Can't open saved study!"
36
37 father = openedStudy.FindComponent("GEOM")
38 if father is None:
39          raise  RuntimeError, "Geom component is not found!  Wrong study is opened." 
40
41
42 #       find   AttributeTextColor
43 #============================================================
44
45 res,A=father.FindAttribute("AttributeTextColor")
46 if res == 0 or A == None:
47         raise  RuntimeError, "Error:  not found AttributeTextColor"
48
49 A = A._narrow(SALOMEDS.AttributeTextColor)
50
51 if A == None :
52         raise  RuntimeError, "Can't create AttributeTextColor attribute"
53
54 c = A.TextColor();
55 if c.R != 234 or c.G != 345 or c.B != 231:
56         print("Error: wrong value of AttributeTextColor")
57