Salome HOME
DCQ: prepare V2.0.0
[modules/kernel.git] / doc / html / INPUT / exemple / Example5.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>#%AttributeName interface(creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute, &nbsp;SaveAs, FindComponent FindAttribute Open%\r
8 #%Attribute methods : SetValue, Value%\r
9 \r
10 # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;create AttributeName &nbsp; &nbsp; \r
11 #===========================================================\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeName&quot;)\r
13 if A == None :\r
14  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
15 A = A._narrow(SALOMEDS.AttributeName)\r
16 \r
17 if A == None :\r
18  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
19 A.SetValue(&quot;AttributesTesting&quot;)\r
20 \r
21 if A.Value() != &quot;AttributesTesting&quot;:\r
22  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Wrong &nbsp;value of AttributeName&quot;\r
23 \r
24 \r
25 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
26 #=================================\r
27 str= os.getenv(&quot;TmpDir&quot;)\r
28 if str == None:\r
29  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
30 file = str+&quot;/test.hdf&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 AttributeName\r
45 #======================================\r
46 \r
47 res,A=father.FindAttribute(&quot;AttributeName&quot;)\r
48 if res == 0 or A == None:\r
49  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeName&quot;\r
50 \r
51 A = A._narrow(SALOMEDS.AttributeName)\r
52 \r
53 if A == None :\r
54  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
55 \r
56 if A.Value() != &quot;AttributesTesting&quot;:\r
57  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Wrong &nbsp;value of AttributeName&quot;\r
58 </PRE>