Salome HOME
Initial version
[modules/gui.git] / doc / salome / tui / KERNEL / exemple / Example15.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>#%AttributeLocalID interface(creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open% &nbsp; &nbsp;\r
8 #%Attribute methods : Value, &nbsp;SetValue%\r
9 \r
10 # &nbsp; &nbsp; &nbsp; create AttributeLocalID\r
11 #=================================\r
12 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeLocalID&quot;)\r
13 if A == None :\r
14  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeLocalID attribute&quot;\r
15 A = A._narrow(SALOMEDS.AttributeLocalID)\r
16 \r
17 A.SetValue(763242882)\r
18 \r
19 if A.Value() != 763242882:\r
20  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributeLocalID&quot;\r
21 \r
22 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
23 #=================================\r
24 str= os.getenv(&quot;TmpDir&quot;)\r
25 if str == None:\r
26  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
27 file = str+&quot;/test.hdf&quot;\r
28 \r
29 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
30 openedStudy = batchmode_geompy.myStudyManager.Open(file);\r
31 \r
32 if openedStudy == None:\r
33  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
34 \r
35 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
36 if father is None:\r
37  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
38 \r
39 \r
40 # &nbsp; &nbsp; find &nbsp;AttributeLocalID\r
41 #=================================\r
42 \r
43 res,A=father.FindAttribute(&quot;AttributeLocalID&quot;)\r
44 if res == 0 or A == None:\r
45  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeLocalID&quot;\r
46 \r
47 A = A._narrow(SALOMEDS.AttributeLocalID)\r
48 \r
49 if A.Value() != 763242882:\r
50  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributeLocalID&quot;\r
51 </PRE>