1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # File : visu_many_objects.py
23 # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
28 # >>> Getting study builder ==================================================
29 myStudy = salome.myStudy
30 myBuilder = myStudy.NewBuilder()
32 # >>> Creating virtual component =============================================
33 myComponent = myBuilder.NewComponent("VIRTUAL")
34 AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
35 AName.SetValue("Virtual")
36 ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment")
37 ACmt.SetValue("Virtual")
39 # >>> Creating objects =======================================================
40 # TO CHANGE TOTAL NUMBER OF OBJECTS, SET PROPER <myNb1>, <myNb2>, <myNb3>
41 # IF YOU DON'T WANT TO ADD REFERENCES, SET <myAddRef> = 0
48 myContainer = myBuilder.NewObject(myComponent)
49 AName = myBuilder.FindOrCreateAttribute(myContainer, "AttributeName")
50 AName.SetValue("References")
51 ACmt = myBuilder.FindOrCreateAttribute(myContainer, "AttributeComment")
52 ACmt.SetValue("Container for objects")
54 for i in range(0,myNb1):
55 myObject1 = myBuilder.NewObject(myComponent)
56 AName = myBuilder.FindOrCreateAttribute(myObject1, "AttributeName")
57 AName.SetValue("Object "+str(i))
58 ACmt = myBuilder.FindOrCreateAttribute(myObject1, "AttributeComment")
59 ACmt.SetValue("Virtual object "+str(i))
61 myRefObject = myBuilder.NewObject(myContainer)
62 myBuilder.Addreference(myRefObject,myObject1);
64 for j in range(0,myNb2):
65 myObject2 = myBuilder.NewObject(myObject1)
66 AName = myBuilder.FindOrCreateAttribute(myObject2, "AttributeName")
67 AName.SetValue("Object "+str(i)+"-"+str(j))
68 ACmt = myBuilder.FindOrCreateAttribute(myObject2, "AttributeComment")
69 ACmt.SetValue("Virtual object "+str(i)+"-"+str(j))
71 myRefObject = myBuilder.NewObject(myContainer)
72 myBuilder.Addreference(myRefObject,myObject2);
74 for k in range(0,myNb3):
75 myObject3 = myBuilder.NewObject(myObject2)
76 AName = myBuilder.FindOrCreateAttribute(myObject3, "AttributeName")
77 AName.SetValue("Object "+str(i)+"-"+str(j)+"-"+str(k))
78 ACmt = myBuilder.FindOrCreateAttribute(myObject3, "AttributeComment")
79 ACmt.SetValue("Virtual object "+str(i)+"-"+str(j)+"-"+str(k))
81 myRefObject = myBuilder.NewObject(myContainer)
82 myBuilder.Addreference(myRefObject,myObject3);
84 # >>> Updating Object Browser ================================================
85 salome.sg.updateObjBrowser(1)
87 # ============================================================================