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