1 <!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
\r
5 <meta http-equiv="Content-Type"
\r
6 content="text/html; charset=iso-8859-1">
\r
8 <meta name="GENERATOR"
\r
9 content="Mozilla/4.73 [en] (WinNT; I) [Netscape]">
\r
10 <title>Main Page</title>
\r
12 <link href="doxygen.css" rel="stylesheet" type="text/css">
\r
20 <td><a href="http://www.opencascade.com"><img src="sources/ogocorp.gif"
\r
21 border="0" height="46" width="122">
\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
34 <h1><a name="page2">Examples</a> </h1>
\r
38 <div align="justify"> <big><b><i> <small>Interfaces:</small></i></b></big><br>
\r
40 <a href="#SALOMEDS::Study_impl">SALOMEDS::Study</a><br>
\r
41 <a href="#SALOMEDS::StudyBuilder_impl">SALOMEDS::StudyBuilder</a><br>
\r
42 <a href="#SALOMEDS::StudyManager_impl">SALOMEDS::StudyManager</a><br>
\r
43 <a href="#SALOMEDS::SObject_impl">SALOMEDS::SObject</a><br>
\r
44 <a href="#SALOMEDS::SComponent_impl">SALOMEDS::SComponent</a><br>
\r
45 <a href="#SALOMEDS::SComponentIterator_impl">SALOMEDS::SComponentIterator</a><br>
\r
46 <a href="#SALOMEDS::ChildIterator_impl">SALOMEDS::ChildIterator<br>
\r
47 </a> <a href="#SALOMEDS::AttributeComment_impl"> SALOMEDS::AttributeComment</a><br>
\r
48 <br>
\r
54 <div align="center"> <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
59 <div align="left"> <big><br>
\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
67 <u>Find GEOMETRY component in the opened study by its name:</u></i><br>
\r
69 str= os.getenv("TmpDir")<br>
\r
70 if str == None:<br>
\r
71 str = "/tmp"<br>
\r
72 file = str+"/test.hdf"<br>
\r
74 openedStudy=batchmode_geompy.myStudyManager.Open(file)<br>
\r
76 father = openedStudy.FindComponent("GEOM")<br>
\r
77 if father is None:<br>
\r
78 raise RuntimeError, "Geom
\r
79 component is not found! Wrong study is opened." <br>
\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
88 <u><i>Find the SObject of the box by its NameAttribute "box":</i></u><br>
\r
91 <div align="left"><br>
\r
94 <div align="left">box = openedStudy.FindObject("box")<br>
\r
95 if box is None :<br>
\r
96 raise RuntimeError, "box was not found! Wrong
\r
97 study is opened."<br>
\r
100 <small><big><big><a class="el"
\r
101 href="interfaceSALOMEDS_1_1SObject.html">SObject</a></big></big><b><big><big> FindObjectID
\r
102 ( in</big> <big><a class="el" href="namespaceSALOMEDS.html#a1">ID</a> </big><em><big>aObjectID
\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
110 <div align="left">box =openedStudy.FindObjectID("0:1:1:2")<br>
\r
113 <div align="left">if box is None :<br>
\r
114 raise RuntimeError, "box was not found! Wrong
\r
118 <small><big><big><a class="el"
\r
119 href="interfaceSALOMEDS_1_1SObject.html">SObject</a></big></big></small><big><b> FindObjectIOR
\r
120 ( in <a class="el" href="namespaceSALOMEDS.html#a1">ID</a> <em>aObjectIOR</em>
\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
126 theResult = myVisu.ImportFile(medFile)<br>
\r
127 aSObj = myStudy.FindObjectIOR(theResult.GetID())<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
133 <u><i>Find SObject by path to it:</i></u><br>
\r
135 # create new auxiliary componen</i>t<br>
\r
136 aComponent = myStudyBuilder.NewComponent("Virtual Component")<br>
\r
138 # create auxiliary subtree<br>
\r
139 aPath = "/Virtual Component/Case1"<br>
\r
140 myStudyBuilder.AddDirectory(aPath)<br>
\r
142 aSObj = myStudy.FindObjectByPath(aPath)<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
148 <u><i>Set context of the study to the created case and get it for printing:</i></u><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
155 #Add a new case 'Case1' to the component 'User data'<br>
\r
156 aBuilder.AddDirectory("/User data/Case1")<br>
\r
158 #Set a study context to '/User data/Case1'<br>
\r
159 aStudy.SetContext("/User data/Case1")<br>
\r
161 #Print the current study context<br>
\r
162 print aStudy.GetContext()<br>
\r
164 </small><i>#result: "/User data/Case1".</i></u><br>
\r
167 <big><b><a class="el" href="interfaceSALOMEDS_1_1ChildIterator.html">ChildIterator</a>
\r
168 NewChildIterator ( in <a class="el"
\r
169 href="interfaceSALOMEDS_1_1SObject.html">SObject</a> aSO ) </b></big><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
174 <i># define file name</i><br>
\r
175 aFileName = datadir + "fra.med"<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
183 <i># get current study and its' SObject </i>
\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
190 <i># create iterator by SObject of the current study</i><br>
\r
191 aMeshIter = myLocalStudy.NewChildIterator(aSObj);<br>
\r
193 <i># iterating in the current study (with the help of created iterator)
\r
194 to find all mesh names</i> <br>
\r
195 while aMeshIter.More() :<br>
\r
196 aMeshSObj = aMeshIter.Value()<br>
\r
197 aMeshIter.Next()<br>
\r
198 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]<br>
\r
199 if anAttr is None :<br>
\r
200 aMeshSObj
\r
201 = aMeshIter.Value()<br>
\r
202 aMeshIter.Next()<br>
\r
203 anAttr
\r
204 = aMeshSObj.FindAttribute("AttributeName")[1]<br>
\r
205 anAttr = anAttr._narrow(SALOMEDS.AttributeName);<br>
\r
206 aMeshName = anAttr.Value()<br>
\r
207 print " ", aMeshName<br>
\r
210 <big><b><a class="el"
\r
211 href="interfaceSALOMEDS_1_1SComponentIterator.html">SComponentIterator</a>
\r
212 NewComponentIterator ()</b></big><br>
\r
214 <u><i>Find the number an names of all components in the study:</i></u><br>
\r
216 aCompItr = myStudy.NewComponentIterator()<br>
\r
219 while aCompItr.More():<br>
\r
220 aComp = aCompItr.Value()<br>
\r
221 aName = aComp.ComponentDataType()<br>
\r
222 print "Component name = ", aName<br>
\r
223 compNb += 1<br>
\r
224 aCompItr.Next()<br>
\r
227 <big><b><a class="el" href="interfaceSALOMEDS_1_1StudyBuilder.html">StudyBuilder</a>
\r
228 NewBuilder ()</b></big><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
235 myBuilder = myStudy.NewBuilder() <br>
\r
238 <big><b><a class="el"
\r
239 href="interfaceSALOMEDS_1_1AttributeStudyProperties.html">AttributeStudyProperties</a>
\r
240 GetProperties ()</b></big><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
245 aProperties = myStudy.GetProperties()<br>
\r
246 if aProperties == None :<br>
\r
247 raise RuntimeError, "Can't create AttributeStudyProperties
\r
249 aProperties = aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>
\r
251 A = aProperties<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
261 <i># change the properties of the study</i><br>
\r
262 if A.IsLocked() == 0 :<br>
\r
263 A.SetUserName("tester"); print 'A.SetUserName("tester"),
\r
264 A.GetUserName() = ', A.GetUserName()<br>
\r
265 A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002),
\r
266 A.GetCreationDate() =', A.GetCreationDate()<br>
\r
267 print "A.IsModified() = ", A.IsModified()<br>
\r
271 <big><b>boolean IsModified ()</b></big><br>
\r
273 <u><i>Find if study is modified:</i></u><br>
\r
275 IsModified = myStudy.IsModified()<br>
\r
277 if IsModified == 1:<br>
\r
278 print "The study is modified and not saved"<br>
\r
281 <big><b>boolean IsEmpty ()</b></big><br>
\r
283 <u><i>Find if study is empty:</i></u><br>
\r
285 IsEmpty = myStudy.IsEmpty()<br>
\r
287 if IsEmpty == 1:<br>
\r
288 print "The study is empty"<br>
\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
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
305 <u><i>Create Geometry SComponent:</i></u><br>
\r
307 myBuilder = myStudy.NewBuilder()<br>
\r
308 father = myBuilder.NewComponent("GEOM")<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
315 <u><i>Define the instance to the created geometry component:</i></u><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
323 myBuilder = myStudy.NewBuilder()<br>
\r
325 father = myBuilder.NewComponent("GEOM")<br>
\r
326 myBuilder.DefineComponentInstance(father,geom)<br>
\r
329 <big><b><a class="el" href="interfaceSALOMEDS_1_1SObject.html">SObject</a>
\r
330 NewObject ( in <a class="el"
\r
331 href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>theFatherObject</i>
\r
334 <u><i>Create box and add it to study:</i></u><br>
\r
336 from batchmode_geompy import *<br>
\r
338 <i># create a box</i><br>
\r
339 box = geom.MakeBox(0,0,0,100,100,150)<br>
\r
341 ior = orb.object_to_string(box)<br>
\r
342 box._set_Name(ior) <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
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
365 <b><big>void RemoveObject ( in <a class="el"
\r
366 href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>anObject</i> )</big></b><br>
\r
368 <u><i># Remove CutPlanes SObject from the StudyBuilder (delete cutplanes):</i></u><br>
\r
370 SObj=myStudy.FindObjectIOR(cutplanes.GetID())<br>
\r
371 myBuilder = newStudy.NewBuilder()<br>
\r
372 myBuilder.RemoveObject(SObj)<br>
\r
375 void LoadWith ( in <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
380 <i><u># Load Visu component:</u></i><br>
\r
382 myBuilder = openedStudy.NewBuilder()<br>
\r
383 SCom=openedStudy.FindComponent("VISU")<br>
\r
384 myBuilder.LoadWith(SCom ,myVisu)<br>
\r
387 <big><b><a class="el" href="interfaceSALOMEDS_1_1GenericAttribute.html">GenericAttribute</a>
\r
388 FindOrCreateAttribute ( in <a class="el"
\r
389 href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>anObject</i>,
\r
390 in string <i>aTypeOfAttribute</i>)</b></big><br>
\r
392 <u><i>Create AttributeName attribute for created component an set value
\r
395 myBuilder = myStudy.NewBuilder()<br>
\r
396 aComponent = myBuilder.NewComponent("User data")<br>
\r
398 anAttr = myBuilder.FindOrCreateAttribute(aComponent, "AttributeName")<br>
\r
400 anAttrName = anAttr._narrow(SALOMEDS.AttributeName) <br>
\r
401 anAttrName.SetValue("User data")<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> </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
409 </b></big><i><u>Find AttributeName attribute of the field and print the
\r
410 field name:</u></i><br>
\r
412 aFieldSObj = myStudy.FindObject("Head, -")<br>
\r
414 myStudyBuilder.FindAttribute( aFieldSObj, anAttr, "AttributeName")<br>
\r
416 raise RuntimeError, "Error: Attribute not
\r
419 anAttr = anAttr._narrow(SALOMEDS.AttributeName);<br>
\r
420 aFieldName = anAttr.Value()<br>
\r
421 print " ", aFieldName<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
428 </b><u><i><small>Remove AttributeSelectable attribute of the field SObject:</small></i></u><br>
\r
430 </b></big>aFieldSObj = myStudy.FindObject("Head, -")<br>
\r
432 myStudyBuilder.RemoveAttribute( aFieldSObj, "AttributeSelectable")<br>
\r
435 </b><b>void Addreference ( in <big> <small><a class="el"
\r
436 href="interfaceSALOMEDS_1_1SObject.html">SObject</a></small></big><small>
\r
437 </small><i>anObject</i>, in </b><b> <a class="el"
\r
438 href="interfaceSALOMEDS_1_1SObject.html">SObject</a> <i>theReferencedObject</i>
\r
441 <u><i>Create a reference between created SObject and the existing field:</i></u><br>
\r
443 aFieldSObj = myStudy.FindObject("Head, -")<br>
\r
444 aNewSObj = myBuilder.NewObject(myVisu)<br>
\r
446 myBuilder.Addreference(aFieldSObj, aNewSObj)<br>
\r
449 </b></big><big><small><i><u><a name="NewCommand_ex"></a></u></i></small></big><big><small><b><big>void
\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
455 </big></b></small></big>A = myStudy.GetProperties()<br>
\r
456 A = aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>
\r
458 myBuilder = myStudy.NewBuilder()<br>
\r
460 myBuilder.NewCommand() <i> # creates a new command</i><br>
\r
462 <i># change the properties of the study</i><br>
\r
463 if A.IsLocked() == 0 :<br>
\r
464 A.SetUserName("tester"); print 'A.SetUserName("tester"),
\r
465 A.GetUserName() = ', A.GetUserName()<br>
\r
466 A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002),
\r
467 A.GetCreationDate() =', A.GetCreationDate()<br>
\r
468 print "A.IsModified() = ", A.IsModified()<br>
\r
471 </small></big>myBuilder.CommitCommand() <i># commits all actions declared
\r
472 within the created command</i><big><br>
\r
475 void CommitCommand()<br>
\r
477 </small><i><small>See the end of the <a href="#NewCommand_ex">previous example</a></small></i><b><br>
\r
480 void AbortCommand ()</b></big><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
485 A = myStudy.GetProperties()<br>
\r
486 A = aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>
\r
488 myBuilder = myStudy.NewBuilder()<br>
\r
490 myBuilder.NewCommand() <i> # creates a new command</i><br>
\r
492 <i># change the properties of the study</i><br>
\r
493 if A.IsLocked() == 0 :<br>
\r
494 A.SetUserName("tester"); print 'A.SetUserName("tester"),
\r
495 A.GetUserName() = ', A.GetUserName()<br>
\r
496 A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002),
\r
497 A.GetCreationDate() =', A.GetCreationDate()<br>
\r
498 print "A.IsModified() = ", A.IsModified()<br>
\r
501 </small></big>myBuilder.AbortCommand() <i># abort all actions declared
\r
502 within the created command</i><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
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
516 A = myStudy.GetProperties()<br>
\r
517 A = aProperties._narrow(SALOMEDS.AttributeStudyProperties)<br>
\r
519 myBuilder = myStudy.NewBuilder()<br>
\r
521 myBuilder.NewCommand() <i> # creates a new command</i><br>
\r
523 <i># change the properties of the study</i><br>
\r
524 if A.IsLocked() == 0 :<br>
\r
525 A.SetUserName("tester"); print 'A.SetUserName("tester"),
\r
526 A.GetUserName() = ', A.GetUserName()<br>
\r
527 A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002),
\r
528 A.GetCreationDate() =', A.GetCreationDate()<br>
\r
529 print "A.IsModified() = ", A.IsModified()<br>
\r
532 </small></big>myBuilder.CommitCommand() <i># commits all actions declared
\r
533 within the created command</i><br>
\r
535 </small></big>myBuilder.Undo() <i># cancels all actions of the command<br>
\r
537 </i>myBuilder.Redo() <i># redoes all actions of the command</i><br>
\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
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
553 <u>Create the study with the name "Test_Study":</u></i><br>
\r
555 myNewStudy = myStudyManager.NewStudy("Test_Study")<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
563 <i><u>Open the study saved in the HDF file:</u></i><br>
\r
565 file = 'saved_study.hdf'<br>
\r
567 openedStudy=myStudyManager.Open(file)<br>
\r
569 if openedStudy == None:<br>
\r
570 raise RuntimeError, "Can't open saved study!"<br>
\r
573 <big><b>void Save (in <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
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
580 </b></big>file = "saved_study.hdf"<br>
\r
581 myMedFile ="medfile.med"<br>
\r
583 openedStudy=myStudyManager.Open(file)<br>
\r
585 myVisu.SetCurrentStudy(openedStudy)<br>
\r
586 myResult = myVisu.ImportFile(myMedFile)<br>
\r
588 myStudyManager.Save(openedStudy, 0)<br>
\r
591 void SaveAs ( in <small><a class="el" href="namespaceSALOMEDS.html#a0">URL</a></small>
\r
592 <i>aUrl</i>, in <small> <a class="el"
\r
593 href="interfaceSALOMEDS_1_1Study.html">Study</a> </small><i>aStudy</i>,
\r
594 <small><em></em></small></b></big><big><b>in boolean <i>theMultifile
\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
600 </big>file = "saved_study.hdf"<br>
\r
601 newfile = "resaved_study.hdf"<br>
\r
603 openedStudy=myStudyManager.Open(file)<br>
\r
604 myStudyManager.SaveAs(newfile, openedStudy, 1)<br>
\r
607 void Close ( in <a class="el"
\r
608 href="interfaceSALOMEDS_1_1Study.html">Study</a> aStudy )</big><br>
\r
610 <u><i>Close just opened study:</i></u><br>
\r
612 file = "saved_study.hdf"<br>
\r
614 openedStudy=myStudyManager.Open(file)<br>
\r
615 myStudyManager.Close(openedStudy)<br>
\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
627 <big><b><a class="el" href="namespaceSALOMEDS.html#a1">ID</a> GetID ()</b></big><br>
\r
629 <u><i>Create new SObject and get its ID:</i></u><br>
\r
631 mySObj = myBuilder.NewObject(myFather)<br>
\r
633 myID = mySObj.GetID()<br>
\r
636 <big><b><a class="el" href="interfaceSALOMEDS_1_1SComponent.html">SComponent</a>
\r
637 GetFatherComponent ()</b></big><br>
\r
639 <u><i>Get father component of the SObject:</i></u><br>
\r
641 myFather = mySObj.GetFatherComponent();<br>
\r
644 <big><b>boolean FindAttribute ( out <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
648 <u><i>Find the AttributeName attribute of the field:</i></u><br>
\r
650 aFieldSObj = myStudy.FindObject("Head, -")<br>
\r
652 res = aFieldSObj.FindAttribute( anAttr, "AttributeName")<br>
\r
654 raise RuntimeError, "Error: Attribute not
\r
658 <big><b><a class="el" href="namespaceSALOMEDS.html#a9">ListOfAttributes</a>
\r
659 GetAllAttributes ()</b></big><br>
\r
661 <i><u>Get list of all attributes of the SObject, find the number of attributes:</u></i><br>
\r
663 attrs = mySObj.GetAllAttributes()<br>
\r
664 aLen = len(attrs) <i># number of attributes</i><br>
\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
677 <big><b>string ComponentDataType ()</b></big><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
682 aCompItr = myStudy.NewComponentIterator() <br>
\r
684 while aCompItr.More():<br>
\r
685 aComp = aCompItr.Value()<br>
\r
686 aName = aComp.ComponentDataType()<br>
\r
687 print "Component name = ", aName<br>
\r
688 aCompItr.Next()<br>
\r
691 <i><b>Other methods are inherited.</b></i><br>
\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
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
709 <big><i><small>See <a href="examples_Study.html#ComponentIterator_ex">another
\r
710 example</a></small></i></big><br>
\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
723 <big><b>boolean More () , void Next (), <a class="el"
\r
724 href="interfaceSALOMEDS_1_1SObject.html">SObject</a> Value ()</b></big><br>
\r
726 <u><i>Print all mesh names of imported MED file with the help of ChildIterator:</i></u><br>
\r
728 aResult = myVisu.ImportFile("MedFile.med")<br>
\r
729 <br>
\r
730 myStudy = theVisu.GetCurrentStudy()<br>
\r
731 aSObj = myLocalStudy.FindObjectIOR(aResult.GetID())<br>
\r
733 aMeshIter = myLocalStudy.NewChildIterator(aSObj); <i> # creating new
\r
734 child iterator</i><br>
\r
736 while aMeshIter.More() :
\r
737
\r
738 <i># check if one more
\r
739 child level exists. </i><br>
\r
740 aMeshSObj = aMeshIter.Value()
\r
741
\r
742 # <i>returns the SObject corresponding
\r
743 to the current object found by the iterator. </i> <br>
\r
744 aMeshIter.Next() <i>
\r
745
\r
746
\r
747 # passes the iterator to the next level. </i><br>
\r
748 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]<br>
\r
749 if anAttr is None :<br>
\r
750
\r
751 aMeshSObj = aMeshIter.Value()<br>
\r
752
\r
753 aMeshIter.Next()<br>
\r
754
\r
755 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]<br>
\r
756 anAttr = anAttr._narrow(SALOMEDS.AttributeName);<br>
\r
757 aMeshName = anAttr.Value()<br>
\r
758 print " ", aMeshName<br>
\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
771 <big><b>string Value (), void SetValue ( in string <i>value </i>)</b></big><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
776 aFieldSObj = myStudy.FindObject("Head, -")<br>
\r
777 anAttr = aFieldSObj.FindAttribute("AttributeComment")[1]<br>
\r
778
\r
779 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);<br>
\r
780
\r
781 aFieldComment = anAttr.Value()<br>
\r
783 print "AttributeComment", anAttr<br>
\r
785 anAttr.SetValue ("My Comment")<br>
\r