1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
\r
3 <!-- hennerik CVSweb $Revision$ -->
\r
4 <TITLE>Example</TITLE></HEAD>
\r
5 <BODY BGCOLOR="#eeeeee">
\r
6 <HR noshade><PRE>#%AttributeSequenceOfReal interface(creations/saving/restoring)%
\r
7 #% AttributeSequenceOfReal : ChangeValue, Add, Value, Remove, Length%
\r
8 #% SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open%
\r
10 # create AttributeSequenceOfReal
\r
11 #=================================
\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeSequenceOfReal")
\r
14 raise RuntimeError, "Can't create AttributeSequenceOfReal attribute"
\r
15 A = A._narrow(SALOMEDS.AttributeSequenceOfReal)
\r
17 raise RuntimeError, "_narrow returns None instead of AttributeSequenceOfReal pointer"
\r
24 print "initial values ",A.Value(1), A.Value(2), A.Value(3), A.Value(4)
\r
26 print "after remove ", A.Value(1), A.Value(2), A.Value(3)
\r
27 A.ChangeValue(2,76.265)
\r
28 print "after second item change", A.Value(1), A.Value(2), A.Value(3)
\r
31 print "Error : wrong length of SequenceOfReal"
\r
32 if A.Value(1) != 0.0293 or A.Value(2) != 76.265 or A.Value(3) != 83.287:
\r
33 print "Error : wrong value of AttributeSequenceOfReal"
\r
35 # save / restore study
\r
36 #=================================
\r
37 str= os.getenv("TmpDir")
\r
39 str = "/tmp"
\r
40 file = str+"/test.hdf"
\r
42 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
\r
43 openedStudy=batchmode_geompy.myStudyManager.Open(file);
\r
45 if openedStudy == None:
\r
46 raise RuntimeError, "Can't open saved study!"
\r
49 father = openedStudy.FindComponent("GEOM")
\r
51 raise RuntimeError, "Geom component is not found! Wrong study is opened."
\r
54 # find AttributeSequenceOfReal
\r
55 #=================================
\r
57 res,A=father.FindAttribute("AttributeSequenceOfReal")
\r
58 if res == 0 or A == None:
\r
59 raise RuntimeError, "Error: not found AttributeSequenceOfReal"
\r
61 A = A._narrow(SALOMEDS.AttributeSequenceOfReal)
\r
64 print "Error : wrong length of SequenceOfReal"
\r
65 if A.Value(1) != 0.0293 or A.Value(2) != 76.265 or A.Value(3) != 83.287:
\r
66 print "Error : wrong value of AttributeSequenceOfReal"
\r
67 print "after restoring ", A.Value(1), A.Value(2), A.Value(3)
\r