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