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>#%AttributeInteger interface(creation/saving/restoring)%
\r
7 #%Methods : FindOrCreateAttribute , Value, SaveAs, SetValue, FindComponent, FindAttribute, Open%
\r
9 # create AttributeInteger
\r
10 #=================================
\r
11 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributeInteger")
\r
13 raise RuntimeError, "Can't create AttributeInteger attribute"
\r
14 A = A._narrow(SALOMEDS.AttributeInteger)
\r
17 if A.Value() != 1000000:
\r
18 raise RuntimeError, "Error : wrong value of AttributeInteger"
\r
20 # save and restore the study
\r
21 #=================================
\r
22 str= os.getenv("TmpDir")
\r
24 str = "/tmp"
\r
26 batchmode_geompy.myStudyManager.SaveAs(str+"/test.hdf", batchmode_geompy.myStudy)
\r
28 openedStudy= batchmode_geompy.myStudyManager.Open(str+"/test.hdf");
\r
30 if openedStudy == None:
\r
31 raise RuntimeError, "Can't open saved study!"
\r
34 father = openedStudy.FindComponent("GEOM")
\r
36 raise RuntimeError, "Geom component is not found! Wrong study is opened."
\r
38 # find AttributeInteger
\r
39 #================================
\r
40 res,A=father.FindAttribute("AttributeInteger")
\r
41 if res == 0 or A == None:
\r
42 raise RuntimeError, "Error: not found AttributeInteger"
\r
43 A = A._narrow(SALOMEDS.AttributeInteger)
\r
44 if A.Value() != 1000000:
\r
45 raise RuntimeError, "Error : wrong value of AttributeInteger after study restoring"
\r