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