Salome HOME
Initial version
[modules/gui.git] / doc / salome / tui / KERNEL / exemple / Example11.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>#%Test AttributeOpened (creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute SaveAs, FindComponent, FindAttribute, Open%\r
8 #%Attribute methods : SetOpened, IsOpened%\r
9 \r
10 # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;create &nbsp; &nbsp;AttributeOpened\r
11 #===========================================================\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeOpened&quot;)\r
13 if A == None :\r
14  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeOpened attribute&quot;\r
15 A = A._narrow(SALOMEDS.AttributeOpened)\r
16 \r
17 if A == None :\r
18  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeOpened attribute&quot;\r
19 \r
20 A.SetOpened(1)\r
21 \r
22 if A.IsOpened() == 0:\r
23  &nbsp; &nbsp; &nbsp; &nbsp;&quot;Error: wrong value of AttributeOpened&quot;\r
24 \r
25 \r
26 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
27 #============================================================\r
28 str= os.getenv(&quot;TmpDir&quot;)\r
29 if str == None:\r
30  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
31 file = str+&quot;/test.hdf&quot;\r
32 \r
33 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
34 openedStudy=batchmode_geompy.myStudyManager.Open(file);\r
35 \r
36 if openedStudy == None:\r
37  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
38 \r
39 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
40 if father is None:\r
41  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
42 \r
43 \r
44 # &nbsp; &nbsp; find &nbsp; AttributeOpened\r
45 #============================================================\r
46 \r
47 res,A=father.FindAttribute(&quot;AttributeOpened&quot;)\r
48 if res == 0 or A == None:\r
49  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeOpened&quot;\r
50 \r
51 A = A._narrow(SALOMEDS.AttributeOpened)\r
52 \r
53 if A == None :\r
54  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeOpened attribute&quot;\r
55 \r
56 if A.IsOpened() == 0:\r
57  &nbsp; &nbsp; &nbsp; &nbsp;&quot;Error: wrong value of AttributeOpened&quot;\r
58 \r
59 </PRE>