Salome HOME
This commit was generated by cvs2git to create tag 'V1_3_0'.
[modules/kernel.git] / doc / html / INPUT / exemple / Example14.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>#%AttributePixMap interface (creations/saving/restoring)%\r
7 #%SALOMEDS methods &nbsp;: FindOrCreateAttribute, SaveAs, FindComponent, FindAttribute, Open%\r
8 #%Attribute methods : SetPixMap, GetPixMap%\r
9 \r
10 #--------------------------------------------------------------------------\r
11 \r
12 #--------------------------------------------------------------------------\r
13 # &nbsp; create &nbsp;AttributePixMap\r
14 #===============================\r
15 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributePixMap&quot;)\r
16 if A == None :\r
17  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributePixMap attribute&quot;\r
18 aPixmap = A._narrow(SALOMEDS.AttributePixMap);\r
19 aPixmap.SetPixMap( &quot;ICON_OBJBROWSER_Geometry&quot; );\r
20 \r
21 if aPixmap.GetPixMap() != &quot;ICON_OBJBROWSER_Geometry&quot;:\r
22  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributePixMap&quot;\r
23 \r
24 \r
25 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
26 #============================================================\r
27 str= os.getenv(&quot;TmpDir&quot;)\r
28 if str == None:\r
29  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
30 file = str+&quot;/test.hdf&quot;\r
31 \r
32 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
33 openedStudy = batchmode_geompy.myStudyManager.Open(file);\r
34 \r
35 if openedStudy == None:\r
36  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
37 \r
38 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
39 if father is None:\r
40  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
41 \r
42 \r
43 # &nbsp; &nbsp; &nbsp; find &nbsp; AttributePixMap\r
44 #============================================================\r
45 \r
46 res,A=father.FindAttribute(&quot;AttributePixMap&quot;)\r
47 if res == 0 or A == None:\r
48  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: AttributePixMap not found &quot;\r
49 \r
50 A = A._narrow(SALOMEDS.AttributePixMap)\r
51 \r
52 if A == None :\r
53  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributePixMap attribute&quot;\r
54 \r
55 if A.GetPixMap() != &quot;ICON_OBJBROWSER_Geometry&quot;:\r
56  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;Error: wrong value of AttributePixMap&quot;\r
57 </PRE>