Salome HOME
e608a092358cf69fb4a42cb1fda76d45efd5e788
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_working_with_groups.doc
1 /*!
2
3 \page tui_working_with_groups_page Working with Groups
4
5 <br><h2>Creation of a group</h2>
6
7 \code
8 import geompy
9 import salome
10 gg = salome.ImportComponentGUI("GEOM")
11
12 # create two vertices
13 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
14 p200 = geompy.MakeVertex(200., 200., 200.)
15
16 # create a box from two points
17 Box = geompy.MakeBoxTwoPnt(p0, p200)
18
19 # create a group from the faces of the box
20 group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
21
22 # add objects to the group
23 SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
24 for i in [0, 3, 5] :
25     FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])
26     geompy.AddObject(group, FaceID)
27
28 # add all selected shapes from the list to the group
29 # (the program doesn't raise error, if some shapes are already included)
30 geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]])
31
32 # remove an object from the group
33 geompy.RemoveObject(group, FaceID)
34
35 # remove all selected shapes from the group
36 # (the program doesn't raise error, if some shapes are not included)
37 geompy.DifferenceList(group, [SubFaceList[2], SubFaceList[3], SubFaceList[4]])
38 id_group1 = geompy.addToStudy(group, "Group1")
39
40 # display the contents of the group
41 gg.createAndDisplayGO(id_group1)
42 salome.sg.updateObjBrowser(1)
43 \endcode
44
45 <br><h2>Adding an object to the group</h2>
46
47 \code
48 import geompy
49 import salome
50 gg = salome.ImportComponentGUI("GEOM")
51
52 # create two vertices
53 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
54 p200 = geompy.MakeVertex(200., 200., 200.)
55
56 # create a box from two points
57 Box = geompy.MakeBoxTwoPnt(p0, p200)
58
59 # create a group from the faces of the box
60 group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
61
62 # add objects to the group
63 SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
64 for i in [0, 3, 5] :
65     FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])
66     geompy.AddObject(group, FaceID)
67 id_group1 = geompy.addToStudy(group, "Group1")
68
69 # display the contents of the group
70 gg.createAndDisplayGO(id_group1)
71 salome.sg.updateObjBrowser(1) 
72 \endcode
73
74 <br><h2>Removing an object from the group</h2>
75
76 \code
77 import geompy
78 import salome
79 gg = salome.ImportComponentGUI("GEOM")
80
81 # create two vertices
82 p0 = geompy.MakeVertex(0.  , 0.  , 0.  )
83 p200 = geompy.MakeVertex(200., 200., 200.)
84
85 # create a box from two points
86 Box = geompy.MakeBoxTwoPnt(p0, p200)
87
88 # create a group from the faces of the box
89 group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
90
91 # add objects to the group
92 SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
93 for i in [0, 3, 5] :
94     FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])
95     geompy.AddObject(group, FaceID)
96
97 # add all selected shapes from the list to the group
98 # (the program doesn't raise errors, if some shapes are already included)
99 geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]])
100
101 # remove an object from the group
102 geompy.RemoveObject(group, FaceID)
103 id_group1 = geompy.addToStudy(group, "Group1")
104
105 # display the contents of the group
106 gg.createAndDisplayGO(id_group1)
107 salome.sg.updateObjBrowser(1) 
108 \endcode
109
110 */