Salome HOME
This commit was generated by cvs2git to create branch 'CCAR_br1'.
[modules/kernel.git] / doc / html / INPUT / exemple / Example7.html
diff --git a/doc/html/INPUT/exemple/Example7.html b/doc/html/INPUT/exemple/Example7.html
new file mode 100755 (executable)
index 0000000..9bf8515
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>\r
+<HEAD>\r
+<!-- hennerik CVSweb $Revision$ -->\r
+<TITLE>Example</TITLE></HEAD>\r
+<BODY BGCOLOR="#eeeeee">\r
+<HR noshade><PRE>#%AttributePersistentRef interface(creations/saving/restoring)%\r
+#%SALOMEDS methods : FindOrCreateAttribute, &nbsp;SaveAs, FindComponent FindAttribute Open%\r
+#%Attribute methods : SetValue, Value%\r
+\r
+# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;create &nbsp; AttributePersistentRef &nbsp; \r
+#===========================================================\r
+A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributePersistentRef&quot;)\r
+if A == None :\r
+ &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributePersistentRef attribute&quot;\r
+A = A._narrow(SALOMEDS.AttributePersistentRef)\r
+\r
+if A == None :\r
+ &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributePersistentRef attribute&quot;\r
+\r
+A.SetValue(&quot;/tmp/test;1&quot;)\r
+\r
+# &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
+#============================================================\r
+str= os.getenv(&quot;TmpDir&quot;)\r
+if str == None:\r
+ &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
+file = str+&quot;/test.hdf&quot;\r
+\r
+batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
+openedStudy = batchmode_geompy.myStudyManager.Open(file);\r
+\r
+if openedStudy == None:\r
+ &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
+\r
+father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
+if father is None:\r
+ &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
+\r
+\r
+# &nbsp; &nbsp; find AttributePersistentRef\r
+#============================================================\r
+\r
+res,A=father.FindAttribute(&quot;AttributePersistentRef&quot;)\r
+if res == 0 or A == None:\r
+ &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributePersistentRef&quot;\r
+\r
+A = A._narrow(SALOMEDS.AttributePersistentRef)\r
+\r
+if A == None :\r
+ &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributePersistentRef attribute&quot;\r
+\r
+if A.Value() != &quot;/tmp/test;1&quot;:\r
+ &nbsp; &nbsp; &nbsp; &nbsp;&quot;Error: wrong value of AttributePersistentRef&quot;\r
+\r
+</PRE>
\ No newline at end of file