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