Salome HOME
This commit was generated by cvs2git to create tag 'V1_4_0b1'.
[modules/kernel.git] / doc / html / INPUT / exemple / Example12.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>\r
2 <HEAD>\r
3 <!-- hennerik CVSweb $Revision$ -->\r
4 <TITLE>Example</TITLE></HEAD>\r
5 <BODY BGCOLOR="#eeeeee">\r
6 <HR noshade><PRE>#%AttributeTextColor interface (creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open%\r
8 #%Attribute methods : SetTextColor &nbsp;TextColor%\r
9 \r
10 \r
11 #--------------------------------------------------------------------------\r
12 # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;create &nbsp; &nbsp;AttributeTextColor\r
13 #===========================================================\r
14 import SALOMEDS_Attributes_idl\r
15 color = SALOMEDS_Attributes_idl._0_SALOMEDS.Color(234,345,231)\r
16 \r
17 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeTextColor&quot;)\r
18 \r
19 if A == None :\r
20  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTextColor attribute&quot;\r
21 A = A._narrow(SALOMEDS.AttributeTextColor)\r
22 \r
23 if A == None :\r
24  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTextColor attribute&quot;\r
25 \r
26 A.SetTextColor(color)\r
27 \r
28 c = A.TextColor();\r
29 \r
30 if c.R != 234 or c.G != 345 or c.B != 231:\r
31  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributeTextColor&quot;\r
32 \r
33 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
34 #============================================================\r
35 str= os.getenv(&quot;TmpDir&quot;)\r
36 if str == None:\r
37  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
38 file = str+&quot;/test.hdf&quot;\r
39 \r
40 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
41 openedStudy = batchmode_geompy.myStudyManager.Open(file);\r
42 \r
43 if openedStudy == None:\r
44  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
45 \r
46 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
47 if father is None:\r
48  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
49 \r
50 \r
51 # &nbsp; &nbsp; &nbsp; find &nbsp; AttributeTextColor\r
52 #============================================================\r
53 \r
54 res,A=father.FindAttribute(&quot;AttributeTextColor&quot;)\r
55 if res == 0 or A == None:\r
56  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeTextColor&quot;\r
57 \r
58 A = A._narrow(SALOMEDS.AttributeTextColor)\r
59 \r
60 if A == None :\r
61  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTextColor attribute&quot;\r
62 \r
63 c = A.TextColor();\r
64 if c.R != 234 or c.G != 345 or c.B != 231:\r
65  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributeTextColor&quot;\r
66 \r
67 </PRE>