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>#%AttributePersistentRef interface(creations/saving/restoring)%
\r
7 #%SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent FindAttribute Open%
\r
8 #%Attribute methods : SetValue, Value%
\r
10 # create AttributePersistentRef
\r
11 #===========================================================
\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, "AttributePersistentRef")
\r
14 raise RuntimeError, "Can't create AttributePersistentRef attribute"
\r
15 A = A._narrow(SALOMEDS.AttributePersistentRef)
\r
18 raise RuntimeError, "Can't create AttributePersistentRef attribute"
\r
20 A.SetValue("/tmp/test;1")
\r
22 # save / restore study
\r
23 #============================================================
\r
24 str= os.getenv("TmpDir")
\r
26 str = "/tmp"
\r
27 file = str+"/test.hdf"
\r
29 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
\r
30 openedStudy = batchmode_geompy.myStudyManager.Open(file);
\r
32 if openedStudy == None:
\r
33 raise RuntimeError, "Can't open saved study!"
\r
35 father = openedStudy.FindComponent("GEOM")
\r
37 raise RuntimeError, "Geom component is not found! Wrong study is opened."
\r
40 # find AttributePersistentRef
\r
41 #============================================================
\r
43 res,A=father.FindAttribute("AttributePersistentRef")
\r
44 if res == 0 or A == None:
\r
45 raise RuntimeError, "Error: not found AttributePersistentRef"
\r
47 A = A._narrow(SALOMEDS.AttributePersistentRef)
\r
50 raise RuntimeError, "Can't create AttributePersistentRef attribute"
\r
52 if A.Value() != "/tmp/test;1":
\r
53 "Error: wrong value of AttributePersistentRef"
\r