Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / doc / html / INPUT / exemple / Example4.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>#%AttributeSequenceOfInteger interface(creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute FindComponent FindAttribute Open Add SaveAs%\r
8 #%AttributeSequenceOfInteger methods : &nbsp;Value, Remove, Length%\r
9 \r
10 # &nbsp; &nbsp; &nbsp; create AttributeSequenceOfInteger &nbsp; &nbsp; &nbsp;\r
11 #==========================================\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeSequenceOfInteger&quot;)\r
13 if A == None :\r
14  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeSequenceOfInteger attribute&quot;\r
15 A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)\r
16 if A == None :\r
17  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeSequenceOfInteger attribute&quot;\r
18 \r
19 A.Add(100)\r
20 A.Add(300)\r
21 A.Add(500)\r
22 A.Add(400)\r
23 A.Add(700)\r
24 \r
25 A.Remove(3)\r
26 A.ChangeValue(4,500)\r
27 \r
28 \r
29 if A.Length() != 4:\r
30  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Wrong length of SequenceOfInteger&quot;\r
31 if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 700:\r
32  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Wrong &nbsp;value of &nbsp;AttributeSequenceOfInteger&quot;\r
33 \r
34 \r
35 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
36 #=================================\r
37 str= os.getenv(&quot;TmpDir&quot;)\r
38 if str == None:\r
39  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
40 file = str+&quot;/test.hdf&quot;\r
41 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
42 openedStudy=batchmode_geompy.myStudyManager.Open(file);\r
43 \r
44 if openedStudy == None:\r
45  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
46 \r
47 \r
48 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
49 if father is None:\r
50  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
51 \r
52 \r
53 # &nbsp; &nbsp; find AttributeSequenceOfInteger\r
54 #======================================\r
55 \r
56 res,A=father.FindAttribute(&quot;AttributeSequenceOfInteger&quot;)\r
57 if res == 0 or A == None:\r
58  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeSequenceOfInteger&quot;\r
59 \r
60 A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)\r
61 \r
62 if A.Length() != 4:\r
63  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Wrong length of SequenceOfInteger&quot;\r
64 if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 700:\r
65  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Wrong &nbsp;value of &nbsp;AttributeSequenceOfInteger&quot;\r
66 </PRE>