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