Salome HOME
This commit was generated by cvs2git to create tag 'V1_3_0'.
[modules/kernel.git] / doc / html / INPUT / sources / static / examples_Study.html
1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">\r
2 <html>\r
3 <head>\r
4             \r
5   <meta http-equiv="Content-Type"\r
6  content="text/html; charset=iso-8859-1">\r
7             \r
8   <meta name="GENERATOR"\r
9  content="Mozilla/4.73 [en] (WinNT; I) [Netscape]">\r
10   <title>Main Page</title>\r
11                    \r
12   <link href="doxygen.css" rel="stylesheet" type="text/css">\r
13 </head>\r
14   <body>\r
15    &nbsp;   \r
16 <center>  \r
17 <table width="96%">\r
18    <tbody>\r
19       <tr>\r
20    <td><a href="http://www.opencascade.com"><img src="sources/ogocorp.gif"\r
21  border="0" height="46" width="122">\r
22         </a></td>\r
23      <td>               \r
24       <div align="right"><a href="http://www.opencascade.org/SALOME/"><img\r
25  src="sources/application.gif" border="0" height="46" width="108">\r
26         </a></div>\r
27    </td>\r
28    </tr>\r
29          \r
30   </tbody>  \r
31 </table>\r
32   </center>\r
33        \r
34 <h1><a name="page2">Examples</a> </h1>\r
35      <br>\r
36   <br>\r
37    \r
38 <div align="justify">&nbsp;&nbsp;&nbsp; &nbsp;<big><b><i> <small>Interfaces:</small></i></b></big><br>\r
39   <br>\r
40   &nbsp; &nbsp; &nbsp; <a href="#SALOMEDS::Study_impl">SALOMEDS::Study</a><br>\r
41   &nbsp;&nbsp;&nbsp; &nbsp; <a href="#SALOMEDS::StudyBuilder_impl">SALOMEDS::StudyBuilder</a><br>\r
42   &nbsp;&nbsp; &nbsp;&nbsp; <a href="#SALOMEDS::StudyManager_impl">SALOMEDS::StudyManager</a><br>\r
43   &nbsp;&nbsp;&nbsp; &nbsp; <a href="#SALOMEDS::SObject_impl">SALOMEDS::SObject</a><br>\r
44 &nbsp;&nbsp;&nbsp; &nbsp; <a href="#SALOMEDS::SComponent_impl">SALOMEDS::SComponent</a><br>\r
45   &nbsp; &nbsp; &nbsp; <a href="#SALOMEDS::SComponentIterator_impl">SALOMEDS::SComponentIterator</a><br>\r
46   &nbsp; &nbsp; &nbsp; <a href="#SALOMEDS::ChildIterator_impl">SALOMEDS::ChildIterator<br>\r
47  </a> &nbsp; &nbsp; &nbsp;<a href="#SALOMEDS::AttributeComment_impl"> SALOMEDS::AttributeComment</a><br>\r
48    &nbsp;&nbsp;&nbsp; &nbsp;<br>\r
49   </div>\r
50   <br>\r
51   <br>\r
52   <br>\r
53    \r
54 <div align="center">&nbsp;&nbsp;&nbsp; &nbsp; <small><small><u><big><big><a\r
55  name="SALOMEDS::Study_impl"></a><font color="#000000"\r
56  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::Study interface</b></big></big></font></big></big></u></small></small><br>\r
57   <br>\r
58    \r
59 <div align="left">                  <big><br>\r
60   </big></div>\r
61   <big><br>\r
62   </big>  \r
63 <div align="left"><b><big><a class="el"\r
64  href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a>  FindComponent(\r
65 in string <i>aComponentName </i>)</big></b><br>\r
66   <i><br>\r
67   <u>Find GEOMETRY component in the opened study by its name:</u></i><br>\r
68   <br>\r
69   &nbsp;&nbsp;&nbsp; str= os.getenv("TmpDir")<br>\r
70   &nbsp;&nbsp;&nbsp; if str == None:<br>\r
71   &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; str = "/tmp"<br>\r
72   &nbsp;&nbsp;&nbsp; file = str+"/test.hdf"<br>\r
73   <br>\r
74   &nbsp;&nbsp;&nbsp; openedStudy=batchmode_geompy.myStudyManager.Open(file)<br>\r
75   <br>\r
76   &nbsp;&nbsp;&nbsp; father = openedStudy.FindComponent("GEOM")<br>\r
77   &nbsp;&nbsp;&nbsp; if father is None:<br>\r
78   &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;raise&nbsp; RuntimeError, "Geom\r
79  component is not found!&nbsp; Wrong study is opened." <br>\r
80   <br>\r
81   <br>\r
82   </div>\r
83    \r
84 <div align="left"><b><big><a class="el"\r
85  href="interfaceSALOMEDS_1_1SObject.html">SObject</a>  FindObject ( in string\r
86 <em>anObjectName </em>)</big></b><br>\r
87   <br>\r
88   <u><i>Find the SObject of the box by its NameAttribute "box":</i></u><br>\r
89   </div>\r
90    \r
91 <div align="left"><br>\r
92   </div>\r
93    \r
94 <div align="left">box = openedStudy.FindObject("box")<br>\r
95   if box is None :<br>\r
96   &nbsp;&nbsp;&nbsp; raise&nbsp; RuntimeError, "box was not found! Wrong\r
97 study  is opened."<br>\r
98   <br>\r
99   <br>\r
100   <small><big><big><a class="el"\r
101  href="interfaceSALOMEDS_1_1SObject.html">SObject</a></big></big><b><big><big>&nbsp;FindObjectID\r
102  ( in</big> <big><a class="el" href="namespaceSALOMEDS.html#a1">ID</a>  </big><em><big>aObjectID\r
103 )</big><br>\r
104   #result: "/User data/Case1". <br>\r
105   </em><big><em></em></big><big><em></em></big></big></b></small><u><i>Find\r
106  the SObject of the box by its ID </i>"</u><u>0:1:1:2"<i>:</i></u><br>\r
107    <br>\r
108   </div>\r
109    \r
110 <div align="left">box =openedStudy.FindObjectID("0:1:1:2")<br>\r
111   </div>\r
112    \r
113 <div align="left">if box is None :<br>\r
114    &nbsp;&nbsp;&nbsp; raise&nbsp; RuntimeError, "box was not found! Wrong \r
115 ID is used."<br>\r
116   <br>\r
117   <br>\r
118   <small><big><big><a class="el"\r
119  href="interfaceSALOMEDS_1_1SObject.html">SObject</a></big></big></small><big><b>&nbsp;FindObjectIOR\r
120  ( in&nbsp;<a class="el" href="namespaceSALOMEDS.html#a1">ID</a>&nbsp;  <em>aObjectIOR</em>\r
121 )</b></big><br>\r
122   <br>\r
123   <u><i>Find the SObject </i></u><u><i>of the result on imported MED file \r
124 by it's IOR:</i></u><br>\r
125   <br>\r
126   theResult = myVisu.ImportFile(medFile)<br>\r
127   aSObj = myStudy.FindObjectIOR(theResult.GetID())<br>\r
128   <br>\r
129   <br>\r
130   <big><b><a class="el" href="interfaceSALOMEDS_1_1SObject.html">SObject</a>\r
131  FindObjectByPath ( in string <i>thePath</i> )</b></big><br>\r
132   <br>\r
133   <u><i>Find SObject by path to it:</i></u><br>\r
134   <i><br>\r
135   # create new auxiliary componen</i>t<br>\r
136   aComponent = myStudyBuilder.NewComponent("Virtual Component")<br>\r
137   <br>\r
138   # create auxiliary subtree<br>\r
139   aPath = "/Virtual Component/Case1"<br>\r
140   myStudyBuilder.AddDirectory(aPath)<br>\r
141   <br>\r
142   aSObj = myStudy.FindObjectByPath(aPath)<br>\r
143   <br>\r
144   <br>\r
145   <big><b>void SetContext ( in string <i>thePath</i>)</b> </big><b><big><big>/</big>\r
146  string GetContext ()</big></b><br>\r
147   <br>\r
148   <u><i>Set context of the study to the created case and get it for printing:</i></u><br>\r
149   <br>\r
150   aComponent = myStudyBuilder.NewComponent("User data")<br>\r
151   anAttr = aBuilder.FindOrCreateAttribute(aComponent, "AttributeName")<br>\r
152   anAttrName = anAttr._narrow(SALOMEDS.AttributeName) <br>\r
153   anAttrName.SetValue("User data")<br>\r
154   <br>\r
155   #Add a new case 'Case1' to the component 'User data'<br>\r
156   aBuilder.AddDirectory("/User data/Case1")<br>\r
157   <br>\r
158   #Set a study context to '/User data/Case1'<br>\r
159   aStudy.SetContext("/User data/Case1")<br>\r
160   <br>\r
161   #Print the current study context<br>\r
162   print aStudy.GetContext()<br>\r
163   <u><small><br>\r
164   </small><i>#result: "/User data/Case1".</i></u><br>\r
165   <br>\r
166   <br>\r
167   <big><b><a class="el" href="interfaceSALOMEDS_1_1ChildIterator.html">ChildIterator</a>\r
168  NewChildIterator ( in&nbsp;<a class="el"\r
169  href="interfaceSALOMEDS_1_1SObject.html">SObject</a>  aSO            ) </b></big><br>\r
170   <br>\r
171   <u><i>Import med file and print all mesh names that this file includes\r
172 (mesh  is a child of the result of imported file):</i></u><br>\r
173   <br>\r
174   <i># define file name</i><br>\r
175   aFileName = datadir + "fra.med"<br>\r
176   <br>\r
177   <i># import file in visu module and get result</i><br>\r
178   theVisu = batchmode_visu.myVisu<br>\r
179   aResult = theVisu.ImportFile(aFileName)<br>\r
180   if aResult is None : raise RuntimeError, "Error"<br>\r
181   else : print "OK"<br>\r
182   &nbsp;<br>\r
183   <i># get current study and its' SObject&nbsp; </i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
184  <br>\r
185   myLocalStudy = theVisu.GetCurrentStudy()<br>\r
186   aSObj = myLocalStudy.FindObjectIOR(aResult.GetID())<br>\r
187   if aSObj is None : raise RuntimeError, "Error"<br>\r
188   else : print "OK"<br>\r
189   <br>\r
190   <i># create iterator by SObject of the current study</i><br>\r
191   aMeshIter = myLocalStudy.NewChildIterator(aSObj);<br>\r
192   <br>\r
193   <i># iterating in the current study (with the help of created iterator) \r
194 to find all mesh names</i> &nbsp;<br>\r
195   while aMeshIter.More() :<br>\r
196   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshSObj = aMeshIter.Value()<br>\r
197   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshIter.Next()<br>\r
198   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anAttr = aMeshSObj.FindAttribute("AttributeName")[1]<br>\r
199   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if anAttr is None :<br>\r
200   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshSObj\r
201  = aMeshIter.Value()<br>\r
202   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshIter.Next()<br>\r
203   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anAttr\r
204  = aMeshSObj.FindAttribute("AttributeName")[1]<br>\r
205   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anAttr = anAttr._narrow(SALOMEDS.AttributeName);<br>\r
206   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshName = anAttr.Value()<br>\r
207   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&nbsp; ", aMeshName<br>\r
208   <br>\r
209   <br>\r
210   <big><b><a class="el"\r
211  href="interfaceSALOMEDS_1_1SComponentIterator.html">SComponentIterator</a> \r
212 NewComponentIterator ()</b></big><br>\r
213  <br>\r
214  <u><i>Find the number an names of all components in the study:</i></u><br>\r
215  <br>\r
216  aCompItr = myStudy.NewComponentIterator()<br>\r
217  <br>\r
218  compNb = 0<br>\r
219  while aCompItr.More():<br>\r
220  &nbsp;&nbsp;&nbsp; aComp = aCompItr.Value()<br>\r
221  &nbsp;&nbsp;&nbsp; aName = aComp.ComponentDataType()<br>\r
222  &nbsp;&nbsp;&nbsp; print "Component name = ", aName<br>\r
223  &nbsp;&nbsp;&nbsp; compNb += 1<br>\r
224  &nbsp;&nbsp;&nbsp; aCompItr.Next()<br>\r
225  <br>\r
226  <br>\r
227  <big><b><a class="el" href="interfaceSALOMEDS_1_1StudyBuilder.html">StudyBuilder</a> \r
228 NewBuilder ()</b></big><br>\r
229   </div>\r
230   </div>\r
231  <br>\r
232  <i><u>Create a new StudyBuilder (uses to add or modify an object in the\r
233 study ):</u></i><br>\r
234  <br>\r
235  myBuilder = myStudy.NewBuilder() <br>\r
236  <br>\r
237  <br>\r
238  <big><b><a class="el"\r
239  href="interfaceSALOMEDS_1_1AttributeStudyProperties.html">AttributeStudyProperties</a> \r
240 GetProperties ()</b></big><br>\r
241  <br>\r
242  <i><u>Get the attribute, which contains the properties of the study, and \r
243 change properties of the study </u></i><u>by changing it</u>: <br>\r
244  <br>\r
245  aProperties = myStudy.GetProperties()<br>\r
246  if aProperties == None :<br>\r
247  &nbsp;&nbsp;&nbsp; raise&nbsp; RuntimeError, "Can't create AttributeStudyProperties \r
248 attribute"<br>\r
249  aProperties&nbsp;= aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>\r
250  <br>\r
251  A = aProperties<br>\r
252  <br>\r
253  <i># print stydy properties</i><br>\r
254  print "A.GetUserName()= ", A.GetUserName()<br>\r
255  res,mm,hh,dd,mnth,yy=A.GetCreationDate()<br>\r
256  print "A.GetCreationDate() = ", mm,hh,dd,mnth,yy<br>\r
257  print "A.GetCreationMode() = ", A.GetCreationMode()<br>\r
258  print "A.IsModified() = ", A.IsModified()<br>\r
259  print "A.IsLocked() = ", A.IsLocked()<br>\r
260  <br>\r
261  <i># change the properties of the study</i><br>\r
262  if A.IsLocked() == 0 :<br>\r
263  &nbsp;&nbsp;&nbsp; A.SetUserName("tester"); print 'A.SetUserName("tester"), \r
264 A.GetUserName() = ', A.GetUserName()<br>\r
265  &nbsp;&nbsp;&nbsp; A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002), \r
266 A.GetCreationDate() =', A.GetCreationDate()<br>\r
267  &nbsp;&nbsp;&nbsp; print "A.IsModified() = ", A.IsModified()<br>\r
268  A.SetLocked(1)<br>\r
269  <br>\r
270  <br>\r
271  <big><b>boolean IsModified ()</b></big><br>\r
272  <br>\r
273  <u><i>Find if study is modified:</i></u><br>\r
274  <br>\r
275  IsModified = myStudy.IsModified()<br>\r
276  <br>\r
277  if IsModified == 1:<br>\r
278  &nbsp;&nbsp;&nbsp; print "The study is modified and not saved"<br>\r
279  <br>\r
280  <br>\r
281  <big><b>boolean IsEmpty ()</b></big><br>\r
282  <br>\r
283  <u><i>Find if study is empty:</i></u><br>\r
284   <br>\r
285   IsEmpty = myStudy.IsEmpty()<br>\r
286   <br>\r
287   if IsEmpty == 1:<br>\r
288   &nbsp;&nbsp;&nbsp; print "The study is empty"<br>\r
289  <br>\r
290  <br>\r
291  <br>\r
292  <br>\r
293  \r
294 <div align="center"><small><small><u><big><big><a\r
295  name="SALOMEDS::StudyBuilder_impl"></a><font color="#000000"\r
296  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::StudyBuilder\r
297 interface</b></big></big></font></big></big></u></small></small><br>\r
298  </div>\r
299  <br>\r
300  <br>\r
301  <br>\r
302  <big><b><a class="el" href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a> \r
303 NewComponent ( in string <i>ComponentDataType</i> )</b></big><br>\r
304  <br>\r
305  <u><i>Create Geometry SComponent:</i></u><br>\r
306  <br>\r
307  myBuilder = myStudy.NewBuilder()<br>\r
308  father = myBuilder.NewComponent("GEOM")<br>\r
309  <br>\r
310  <big><b><br>\r
311  void DefineComponentInstance ( in <a class="el"\r
312  href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a> <i>aComponent</i>,\r
313 in Object <i>ComponentIOR</i> )</b></big><br>\r
314  <br>\r
315  <u><i>Define the instance to the created geometry component:</i></u><br>\r
316  <br>\r
317  <i># find geom component</i><br>\r
318  myLCC = batchmode_salome.lcc<br>\r
319  geom = myLCC.FindOrLoadComponent("FactoryServer", "Geometry")<br>\r
320  geom = geom._narrow(GEOM.GEOM_Gen)<br>\r
321  geom.GetCurrentStudy(myStudyId)<br>\r
322  <br>\r
323  myBuilder = myStudy.NewBuilder()<br>\r
324  <br>\r
325  father = myBuilder.NewComponent("GEOM")<br>\r
326  myBuilder.DefineComponentInstance(father,geom)<br>\r
327  <br>\r
328  <br>\r
329  <big><b><a class="el" href="interfaceSALOMEDS_1_1SObject.html">SObject</a> \r
330 NewObject ( in&nbsp;<a class="el"\r
331  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>theFatherObject</i>\r
332 )</b></big><br>\r
333  <br>\r
334  <u><i>Create box and add it to study:</i></u><br>\r
335  <br>\r
336  from batchmode_geompy import *<br>\r
337  <br>\r
338  <i># create a box</i><br>\r
339  box = geom.MakeBox(0,0,0,100,100,150)<br>\r
340  <br>\r
341  ior = orb.object_to_string(box)<br>\r
342  box._set_Name(ior)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>\r
343  <br>\r
344  <i># create Geometry SComponent</i><br>\r
345  father = myBuilder.NewComponent("GEOM")<br>\r
346  A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");<br>\r
347  FName = A1._narrow(SALOMEDS.AttributeName)<br>\r
348  FName.SetValue("Geometry")<br>\r
349  myBuilder.DefineComponentInstance(father,geom)<br>\r
350  <br>\r
351  <i># add box to Study</i><br>\r
352  myBuilder.NewCommand()<br>\r
353  newObj = myBuilder.NewObject(father)<br>\r
354  A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");<br>\r
355  ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)<br>\r
356  ObjIOR.SetValue(ior)<br>\r
357  A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");<br>\r
358  ObjName = A2._narrow(SALOMEDS.AttributeName)<br>\r
359  ObjName.SetValue("Common_operation")<br>\r
360  id = newObj.GetID()<br>\r
361  box._set_StudyShapeId(id)<br>\r
362  myBuilder.CommitCommand()<br>\r
363  <br>\r
364  <br>\r
365  <b><big>void RemoveObject ( in&nbsp;<a class="el"\r
366  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>anObject</i> )</big></b><br>\r
367  <br>\r
368  <u><i># Remove CutPlanes SObject from the StudyBuilder (delete cutplanes):</i></u><br>\r
369  <br>\r
370  SObj=myStudy.FindObjectIOR(cutplanes.GetID())<br>\r
371  myBuilder = newStudy.NewBuilder()<br>\r
372  myBuilder.RemoveObject(SObj)<br>\r
373  <br>\r
374  <b><big><br>\r
375  void LoadWith ( in&nbsp;<a class="el"\r
376  href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a><i> sco</i>, in\r
377 <a class="el" href="interfaceSALOMEDS_1_1Driver.html">Driver</a> <i>Engine</i>\r
378 ) raises (<a class="el" href="exceptionSALOME_1_1SALOME__Exception.html">SALOME::SALOME_Exception</a>)</big></b><br>\r
379  <br>\r
380  <i><u># Load Visu component:</u></i><br>\r
381  <br>\r
382  myBuilder = openedStudy.NewBuilder()<br>\r
383  SCom=openedStudy.FindComponent("VISU")<br>\r
384  myBuilder.LoadWith(SCom ,myVisu)<br>\r
385  <br>\r
386  <br>\r
387  <big><b><a class="el" href="interfaceSALOMEDS_1_1GenericAttribute.html">GenericAttribute</a> \r
388 FindOrCreateAttribute ( in&nbsp;<a class="el"\r
389  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>anObject</i>,&nbsp;\r
390 in string <i>aTypeOfAttribute</i>)</b></big><br>\r
391  <br>\r
392  <u><i>Create AttributeName attribute for created component an set value\r
393 to it:</i></u><br>\r
394  <br>\r
395  myBuilder = myStudy.NewBuilder()<br>\r
396  aComponent = myBuilder.NewComponent("User data")<br>\r
397  <br>\r
398  anAttr = myBuilder.FindOrCreateAttribute(aComponent, "AttributeName")<br>\r
399  <br>\r
400  anAttrName = anAttr._narrow(SALOMEDS.AttributeName) <br>\r
401  anAttrName.SetValue("User data")<br>\r
402  <br>\r
403  <br>\r
404  <big><b>boolean FindAttribute ( in  <a class="el"\r
405  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>anObject,</i> out<i>&nbsp;</i><a\r
406  class="el" href="interfaceSALOMEDS_1_1GenericAttribute.html">GenericAttribute</a><i> \r
407 anAttribute</i>, in string <i>aTypeOfAttribute</i> )</b></big><br>\r
408  <big><b><br>\r
409  </b></big><i><u>Find AttributeName attribute of the field and print the\r
410 field name:</u></i><br>\r
411  <br>\r
412  aFieldSObj&nbsp; = myStudy.FindObject("Head, -")<br>\r
413  <br>\r
414  myStudyBuilder.FindAttribute( aFieldSObj, anAttr, "AttributeName")<br>\r
415  if res == 0:<br>\r
416   &nbsp;&nbsp;&nbsp; raise&nbsp; RuntimeError, "Error:&nbsp; Attribute not \r
417 found"<br>\r
418  <br>\r
419  anAttr = anAttr._narrow(SALOMEDS.AttributeName);<br>\r
420  aFieldName = anAttr.Value()<br>\r
421  print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ", aFieldName<br>\r
422  <br>\r
423  <br>\r
424  <b><big>void RemoveAttribute ( in  <a class="el"\r
425  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>anObject</i>, in\r
426 string <i>aTypeOfAttribute</i> )</big></b><br>\r
427  <big><b><br>\r
428  </b><u><i><small>Remove AttributeSelectable attribute of the field SObject:</small></i></u><br>\r
429  <b><br>\r
430  </b></big>aFieldSObj&nbsp; = myStudy.FindObject("Head, -")<br>\r
431   <br>\r
432   myStudyBuilder.RemoveAttribute( aFieldSObj, "AttributeSelectable")<br>\r
433  <big><b><br>\r
434  <br>\r
435  </b><b>void Addreference ( in&nbsp;<big>  <small><a class="el"\r
436  href="interfaceSALOMEDS_1_1SObject.html">SObject</a></small></big><small> \r
437 </small><i>anObject</i>, in&nbsp;</b><b>  <a class="el"\r
438  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>theReferencedObject</i>\r
439 )</b></big><br>\r
440  <br>\r
441  <u><i>Create a reference between created SObject and the existing field:</i></u><br>\r
442  <br>\r
443  aFieldSObj&nbsp; = myStudy.FindObject("Head, -")<br>\r
444  aNewSObj = myBuilder.NewObject(myVisu)<br>\r
445  <br>\r
446  myBuilder.Addreference(aFieldSObj, aNewSObj)<br>\r
447  <big><b><br>\r
448  <br>\r
449  </b></big><big><small><i><u><a name="NewCommand_ex"></a></u></i></small></big><big><small><b><big>void \r
450 NewCommand ()<br>\r
451  <br>\r
452  </big></b><i><u>Create new command wich containes actions for changing the \r
453 properties of the study:</u></i><b><big><br>\r
454  <br>\r
455  </big></b></small></big>A&nbsp;= myStudy.GetProperties()<br>\r
456  A&nbsp;= aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>\r
457   <br>\r
458  myBuilder = myStudy.NewBuilder()<br>\r
459   <br>\r
460  myBuilder.NewCommand() <i> # creates a new command</i><br>\r
461   <br>\r
462   <i># change the properties of the study</i><br>\r
463   if A.IsLocked() == 0 :<br>\r
464   &nbsp;&nbsp;&nbsp; A.SetUserName("tester"); print 'A.SetUserName("tester"), \r
465 A.GetUserName() = ', A.GetUserName()<br>\r
466   &nbsp;&nbsp;&nbsp; A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002), \r
467 A.GetCreationDate() =', A.GetCreationDate()<br>\r
468   &nbsp;&nbsp;&nbsp; print "A.IsModified() = ", A.IsModified()<br>\r
469   A.SetLocked(1)<br>\r
470  <big><small><br>\r
471  </small></big>myBuilder.CommitCommand() <i># commits all actions declared \r
472 within the created command</i><big><br>\r
473  <b><br>\r
474  <br>\r
475  void CommitCommand()<br>\r
476  </b><small><br>\r
477  </small><i><small>See the end of the <a href="#NewCommand_ex">previous example</a></small></i><b><br>\r
478  <br>\r
479  <br>\r
480  void AbortCommand ()</b></big><br>\r
481  <br>\r
482  <big><small><i><u>Create new command wich containes actions for changing \r
483 the properties of the study, cancel all declared actions:</u></i></small></big><br>\r
484  <br>\r
485  A&nbsp;= myStudy.GetProperties()<br>\r
486   A&nbsp;= aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>\r
487    <br>\r
488   myBuilder = myStudy.NewBuilder()<br>\r
489    <br>\r
490   myBuilder.NewCommand() <i> # creates a new command</i><br>\r
491    <br>\r
492    <i># change the properties of the study</i><br>\r
493    if A.IsLocked() == 0 :<br>\r
494    &nbsp;&nbsp;&nbsp; A.SetUserName("tester"); print 'A.SetUserName("tester"), \r
495 A.GetUserName() = ', A.GetUserName()<br>\r
496    &nbsp;&nbsp;&nbsp; A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002), \r
497 A.GetCreationDate() =', A.GetCreationDate()<br>\r
498    &nbsp;&nbsp;&nbsp; print "A.IsModified() = ", A.IsModified()<br>\r
499    A.SetLocked(1)<br>\r
500   <big><small><br>\r
501   </small></big>myBuilder.AbortCommand() <i># abort all actions declared\r
502 within the created command</i><br>\r
503  <br>\r
504  <br>\r
505  <big><b>void Undo () raises (<a class="el"\r
506  href="exceptionSALOMEDS_1_1StudyBuilder_1_1LockProtection.html">LockProtection</a>)</b><b> \r
507 <small>, </small></b></big><br>\r
508  <big><b>void Redo ()</b></big> <big><b>raises (<a class="el"\r
509  href="exceptionSALOMEDS_1_1StudyBuilder_1_1LockProtection.html">LockProtection</a>)</b></big><br>\r
510  <br>\r
511  <big><small><i><u>Create new command wich containes actions for changing \r
512 the properties of the study, <br>\r
513  cancel all declared actions and then redo it with the help of undo/redo\r
514 mechanism:</u></i></small></big><br>\r
515  <br>\r
516  A&nbsp;= myStudy.GetProperties()<br>\r
517    A&nbsp;= aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>\r
518     <br>\r
519    myBuilder = myStudy.NewBuilder()<br>\r
520     <br>\r
521    myBuilder.NewCommand() <i> # creates a new command</i><br>\r
522     <br>\r
523     <i># change the properties of the study</i><br>\r
524     if A.IsLocked() == 0 :<br>\r
525     &nbsp;&nbsp;&nbsp; A.SetUserName("tester"); print 'A.SetUserName("tester"), \r
526 A.GetUserName() = ', A.GetUserName()<br>\r
527     &nbsp;&nbsp;&nbsp; A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002), \r
528 A.GetCreationDate() =', A.GetCreationDate()<br>\r
529     &nbsp;&nbsp;&nbsp; print "A.IsModified() = ", A.IsModified()<br>\r
530     A.SetLocked(1)<br>\r
531    <big><small><br>\r
532  </small></big>myBuilder.CommitCommand() <i># commits all actions declared \r
533 within the created command</i><br>\r
534  <big><small><br>\r
535   </small></big>myBuilder.Undo() <i># cancels all actions of the command<br>\r
536  <br>\r
537  </i>myBuilder.Redo() <i># redoes all actions of the command</i><br>\r
538  <i><br>\r
539  <br>\r
540  <br>\r
541  </i> \r
542 <div align="center"><small><small><u><big><big><a\r
543  name="SALOMEDS::StudyManager_impl"></a><font color="#000000"\r
544  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::StudyManager\r
545 interface</b></big></big></font></big></big></u></small></small><br>\r
546  </div>\r
547  <i><br>\r
548  <br>\r
549  <br>\r
550  </i><big><b><a class="el" href="interfaceSALOMEDS_1_1Study.html">Study</a> \r
551 NewStudy ( in string <i>study_name</i> )</b></big><br>\r
552  <i><br>\r
553  <u>Create the study with the name "Test_Study":</u></i><br>\r
554  <br>\r
555  myNewStudy = myStudyManager.NewStudy("Test_Study")<br>\r
556  <br>\r
557  <br>\r
558  <big><b><a class="el" href="interfaceSALOMEDS_1_1Study.html">Study</a> Open\r
559 ( in </b></big><a class="el" href="namespaceSALOMEDS.html#a0">URL</a><big><b> \r
560 <i>aStudyUrl</i> ) raises </b></big>(<a class="el"\r
561  href="exceptionSALOME_1_1SALOME__Exception.html">SALOME::SALOME_Exception</a>)<br>\r
562  <br>\r
563  <i><u>Open the study saved in the HDF file:</u></i><br>\r
564  <br>\r
565  file = 'saved_study.hdf'<br>\r
566  <br>\r
567  openedStudy=myStudyManager.Open(file)<br>\r
568  <br>\r
569  if openedStudy == None:<br>\r
570  &nbsp;&nbsp;&nbsp; raise&nbsp; RuntimeError, "Can't open saved study!"<br>\r
571  <br>\r
572  <br>\r
573  <big><b>void Save (in&nbsp;<a class="el"\r
574  href="interfaceSALOMEDS_1_1Study.html">Study</a> <i>aStudy</i>, in boolean\r
575 <i>theMultifile</i> )</b></big><big><b><br>\r
576  <br>\r
577  </b><small><u><i>Open study, import med file into it and save with the old \r
578 path and filename:</i></u></small><b><br>\r
579  <br>\r
580  </b></big>file = "saved_study.hdf"<br>\r
581  myMedFile ="medfile.med"<br>\r
582   <br>\r
583   openedStudy=myStudyManager.Open(file)<br>\r
584   <br>\r
585  myVisu.SetCurrentStudy(openedStudy)<br>\r
586  myResult = myVisu.ImportFile(myMedFile)<br>\r
587  <br>\r
588  myStudyManager.Save(openedStudy, 0)<br>\r
589  <br>\r
590  <big><b><br>\r
591  void SaveAs ( in <small><a class="el" href="namespaceSALOMEDS.html#a0">URL</a></small> \r
592 <i>aUrl</i>, in&nbsp;<small> <a class="el"\r
593  href="interfaceSALOMEDS_1_1Study.html">Study</a> </small><i>aStudy</i>,\r
594 &nbsp;<small><em></em></small></b></big><big><b>in boolean <i>theMultifile\r
595 </i>)</b><br>\r
596  <br>\r
597  <small><u><i>Open study from the file and resave it in several files (using \r
598 Multifile option while saving)</i></u></small><br>\r
599  <br>\r
600  </big>file = "saved_study.hdf"<br>\r
601  newfile = "resaved_study.hdf"<br>\r
602  <br>\r
603  openedStudy=myStudyManager.Open(file)<br>\r
604    myStudyManager.SaveAs(newfile, openedStudy, 1)<br>\r
605  <big><br>\r
606  <br>\r
607  void Close ( in&nbsp; <a class="el"\r
608  href="interfaceSALOMEDS_1_1Study.html">Study</a> aStudy )</big><br>\r
609  <br>\r
610  <u><i>Close just opened study:</i></u><br>\r
611  <br>\r
612  file = "saved_study.hdf"<br>\r
613  <br>\r
614   openedStudy=myStudyManager.Open(file)<br>\r
615     myStudyManager.Close(openedStudy)<br>\r
616  <br>\r
617  <br>\r
618  <br>\r
619  \r
620 <div align="center"><small><small><u><big><big><a\r
621  name="SALOMEDS::SObject_impl"></a><font color="#000000"\r
622  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::SObject interface</b></big></big></font></big></big></u></small></small><br>\r
623  </div>\r
624  <br>\r
625  <br>\r
626  <br>\r
627  <big><b><a class="el" href="namespaceSALOMEDS.html#a1">ID</a> GetID ()</b></big><br>\r
628  <br>\r
629  <u><i>Create new SObject and get its ID:</i></u><br>\r
630  <br>\r
631  mySObj = myBuilder.NewObject(myFather)<br>\r
632  <br>\r
633  myID = &nbsp;mySObj.GetID()<br>\r
634  <br>\r
635  <br>\r
636  <big><b><a class="el" href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a> \r
637 GetFatherComponent ()</b></big><br>\r
638  <br>\r
639  <u><i>Get father component of the SObject:</i></u><br>\r
640  <br>\r
641  myFather = mySObj.GetFatherComponent();<br>\r
642  <br>\r
643  <br>\r
644  <big><b>boolean FindAttribute ( out&nbsp;<a class="el"\r
645  href="interfaceSALOMEDS_1_1GenericAttribute.html">GenericAttribute</a> <i>anAttribute</i>,\r
646 in string <i>aTypeOfAttribute </i>)</b></big><br>\r
647  <br>\r
648  <u><i>Find the AttributeName attribute of the field:</i></u><br>\r
649  <br>\r
650  aFieldSObj&nbsp; = myStudy.FindObject("Head, -")<br>\r
651   <br>\r
652   res = aFieldSObj.FindAttribute( anAttr, "AttributeName")<br>\r
653   if res == 0:<br>\r
654    &nbsp;&nbsp;&nbsp; raise&nbsp; RuntimeError, "Error:&nbsp; Attribute not \r
655 found"<br>\r
656  <br>\r
657  <br>\r
658  <big><b><a class="el" href="namespaceSALOMEDS.html#a9">ListOfAttributes</a> \r
659 GetAllAttributes ()</b></big><br>\r
660  <br>\r
661  <i><u>Get list of all attributes of the SObject, find the number of attributes:</u></i><br>\r
662  <br>\r
663  attrs = mySObj.GetAllAttributes()<br>\r
664  aLen = len(attrs) <i># number of attributes</i><br>\r
665  <br>\r
666  <br>\r
667  <br>\r
668  <br>\r
669  \r
670 <div align="center"><small><small><u><big><big><a\r
671  name="SALOMEDS::SComponent_impl"></a><font color="#000000"\r
672  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::SComponent interface</b></big></big></font></big></big></u></small></small><br>\r
673  </div>\r
674  <br>\r
675  <br>\r
676  <br>\r
677  <big><b>string ComponentDataType ()</b></big><br>\r
678  <br>\r
679  <i><u><a name="ComponentIterator_ex"></a>Print names of all components wich \r
680 the study contains:</u></i><br>\r
681  <br>\r
682  aCompItr = myStudy.NewComponentIterator() <br>\r
683  <br>\r
684  while aCompItr.More():<br>\r
685  &nbsp;&nbsp;&nbsp; aComp = aCompItr.Value()<br>\r
686  &nbsp;&nbsp;&nbsp; aName = aComp.ComponentDataType()<br>\r
687  &nbsp;&nbsp;&nbsp; print "Component name = ", aName<br>\r
688  &nbsp;&nbsp;&nbsp; aCompItr.Next()<br>\r
689  <br>\r
690  <br>\r
691  <i><b>Other methods are inherited.</b></i><br>\r
692  <br>\r
693  <br>\r
694  <br>\r
695  <br>\r
696  \r
697 <div align="center"><small><small><u><big><big><a\r
698  name="SALOMEDS::SComponentIterator_impl"></a><font color="#000000"\r
699  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::SComponentIterator\r
700  interface</b></big></big></font></big></big></u></small></small><br>\r
701  </div>\r
702  <br>\r
703  <br>\r
704  <br>\r
705  <big><b>boolean More (), </b><b>void Next (), </b></big><big><b><a\r
706  class="el" href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a> Value\r
707 ()</b></big><br>\r
708  <br>\r
709  <big><i><small>See <a href="examples_Study.html#ComponentIterator_ex">another \r
710 example</a></small></i></big><br>\r
711  <br>\r
712  &nbsp;&nbsp; <br>\r
713  <br>\r
714  \r
715 <div align="center"><small><small><u><big><big><a\r
716  name="SALOMEDS::ChildIterator_impl"></a><font color="#000000"\r
717  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::ChildIterator\r
718  interface</b></big></big></font></big></big></u></small></small><br>\r
719  </div>\r
720  <br>\r
721  <br>\r
722  <br>\r
723  <big><b>boolean More () , void Next (), <a class="el"\r
724  href="interfaceSALOMEDS_1_1SObject.html">SObject</a> Value ()</b></big><br>\r
725  <br>\r
726  <u><i>Print all mesh names of imported MED file with the help of ChildIterator:</i></u><br>\r
727  <br>\r
728  aResult = myVisu.ImportFile("MedFile.med")<br>\r
729  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>\r
730  myStudy = theVisu.GetCurrentStudy()<br>\r
731  aSObj = myLocalStudy.FindObjectIOR(aResult.GetID())<br>\r
732  <br>\r
733  aMeshIter = myLocalStudy.NewChildIterator(aSObj);&nbsp;<i> # creating new \r
734 child iterator</i><br>\r
735  <br>\r
736  while aMeshIter.More() : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \r
737 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;\r
738 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <i># check if one more\r
739 child level exists.     </i><br>\r
740  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshSObj = aMeshIter.Value() \r
741 &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \r
742 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# <i>returns the SObject corresponding \r
743 to the current object found by the iterator.      </i>&nbsp;<br>\r
744  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshIter.Next() <i>&nbsp; &nbsp; \r
745 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \r
746 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \r
747 &nbsp; &nbsp;# passes the iterator to the next level.     </i><br>\r
748  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anAttr = aMeshSObj.FindAttribute("AttributeName")[1]<br>\r
749  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if anAttr is None :<br>\r
750  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \r
751 aMeshSObj = aMeshIter.Value()<br>\r
752  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; \r
753 &nbsp; aMeshIter.Next()<br>\r
754  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \r
755 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]<br>\r
756  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anAttr = anAttr._narrow(SALOMEDS.AttributeName);<br>\r
757  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aMeshName = anAttr.Value()<br>\r
758  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "&nbsp; ", aMeshName<br>\r
759  <br>\r
760  <br>\r
761  <br>\r
762  \r
763 <div align="center"><small><small><u><big><big><a\r
764  name="SALOMEDS::AttributeComment_impl"\r
765  href="#SALOMEDS::AttributeComment_impl"></a><font color="#000000"\r
766  face="Helvetica, Arial, sans-serif"><big><big><b>SALOMEDS::AttributeComment\r
767  interface</b></big></big></font></big></big></u></small></small><br>\r
768  </div>\r
769  <br>\r
770  <br>\r
771  <big><b>string Value (), &nbsp;void SetValue ( in string <i>value </i>)</b></big><br>\r
772  <br>\r
773  <u><i>Find the AttributeComment attribute of the "Head" field in the study, \r
774 print it, then change it to "My Comment" string:</i></u><br>\r
775  <br>\r
776  aFieldSObj&nbsp; = myStudy.FindObject("Head, -")<br>\r
777  anAttr = aFieldSObj.FindAttribute("AttributeComment")[1]<br>\r
778  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \r
779 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);<br>\r
780  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \r
781 aFieldComment = anAttr.Value()<br>\r
782  <br>\r
783  print "AttributeComment", anAttr<br>\r
784  <br>\r
785  anAttr.SetValue ("My Comment")<br>\r
786  \r
787 <pre></pre>\r
788  <br>\r
789 </body>\r
790 </html>\r