Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / doc / html / INPUT / exemple / Example1.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>\r
2 <HEAD>\r
3 <!-- hennerik CVSweb $Revision$ -->\r
4 <TITLE>Exemple</TITLE></HEAD>\r
5 <BODY BGCOLOR="#eeeeee">\r
6 <HR noshade><PRE>#%AttributeReal interface (creations/saving/restoring)%\r
7 #%Methods : FindOrCreateAttribute, Value, SaveAs, SetValue, FindComponent, FindAttribute, Open%\r
8 \r
9 \r
10 # &nbsp; &nbsp; &nbsp; create AttributeReal &nbsp; &nbsp; &nbsp;\r
11 #=================================\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeReal&quot;)\r
13 if A == None :\r
14  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeReal attribute&quot;\r
15 A = A._narrow(SALOMEDS.AttributeReal)\r
16 A.SetValue(0.0001)\r
17 if A.Value() != 0.0001:\r
18  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error : wrong value of &nbsp;AttributeReal&quot;\r
19 \r
20 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
21 #=================================\r
22 \r
23 str= os.getenv(&quot;TmpDir&quot;)\r
24 if str == None:\r
25  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
26 file = str+&quot;/test.hdf&quot;\r
27 \r
28 #file = &quot;/tmp/ggg.hdf&quot;\r
29 \r
30 print &quot; ------- &nbsp;We will save to&quot;, file, &quot;-----------&quot;\r
31 \r
32 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
33 openedStudy=batchmode_geompy.myStudyManager.Open(file)\r
34 \r
35 if openedStudy == None:\r
36  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
37 \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 AttributeReal\r
45 #=================================\r
46 \r
47 res,A=father.FindAttribute(&quot;AttributeReal&quot;)\r
48 if res == 0 or A == None:\r
49  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeReal&quot;\r
50 \r
51 A = A._narrow(SALOMEDS.AttributeReal)\r
52 if A.Value() != 0.0001:\r
53  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error : wrong value of &nbsp;AttributeReal&quot;\r
54 </PRE>