Salome HOME
Merge from BR_plugins_pbyacs 03/04/2013
[modules/geom.git] / doc / salome / examples / working_with_groups_ex03.py
1 # Removing an object from the group
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9
10 # create two vertices
11 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
12 p200 = geompy.MakeVertex(200., 200., 200.)
13
14 # create a box from two points
15 Box = geompy.MakeBoxTwoPnt(p0, p200)
16
17 # create a group from the faces of the box
18 group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
19
20 # add objects to the group
21 SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
22 for i in [0, 3, 5] :
23     FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])
24     geompy.AddObject(group, FaceID)
25
26 # add all selected shapes from the list to the group
27 # (the program doesn't raise errors, if some shapes are already included)
28 geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]])
29
30 # remove an object from the group
31 geompy.RemoveObject(group, FaceID)
32 id_group1 = geompy.addToStudy(group, "Group1")
33
34 # display the contents of the group
35 gg.createAndDisplayGO(id_group1)
36 salome.sg.updateObjBrowser(1)