Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Working with Groups


Creation of a group

1 # Creation of a 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 error, 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 
33 # remove all selected shapes from the group
34 # (the program doesn't raise error, if some shapes are not included)
35 geompy.DifferenceList(group, [SubFaceList[2], SubFaceList[3], SubFaceList[4]])
36 id_group1 = geompy.addToStudy(group, "Group1")
37 
38 # display the contents of the group
39 gg.createAndDisplayGO(id_group1)
40 salome.sg.updateObjBrowser(True)

Download this script


Adding an object to the group

1 # Adding an object to 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 id_group1 = geompy.addToStudy(group, "Group1")
26 
27 # display the contents of the group
28 gg.createAndDisplayGO(id_group1)
29 salome.sg.updateObjBrowser(True)

Download this script


Removing an object from the group

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(True)

Download this script


Union Groups

1 # Union Groups
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 # create a box and some groups of faces on it
10 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
11 Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
12 geompy.UnionIDs(Group_1, [13, 23])
13 Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
14 geompy.UnionIDs(Group_2, [3, 27])
15 Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
16 geompy.UnionIDs(Group_3, [33, 23])
17 Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
18 geompy.UnionIDs(Group_4, [31, 27])
19 
20 # union groups
21 Group_U_1_2 = geompy.UnionGroups(Group_1, Group_2)
22 Group_UL_3_4 = geompy.UnionListOfGroups([Group_3, Group_4])
23 
24 # publish shapes
25 geompy.addToStudy(Box_1, 'Box_1')
26 geompy.addToStudyInFather(Box_1, Group_1, 'Group_1')
27 geompy.addToStudyInFather(Box_1, Group_2, 'Group_2')
28 geompy.addToStudyInFather(Box_1, Group_3, 'Group_3')
29 geompy.addToStudyInFather(Box_1, Group_4, 'Group_4')
30 geompy.addToStudyInFather(Box_1, Group_U_1_2, 'Group_U_1_2')
31 geompy.addToStudyInFather(Box_1, Group_UL_3_4, 'Group_UL_3_4')
32 salome.sg.updateObjBrowser(True)

Download this script


Intersect Groups

1 # Intersect Groups
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 # create a box and some groups of faces on it
10 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
11 Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
12 geompy.UnionIDs(Group_1, [13, 23])
13 Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
14 geompy.UnionIDs(Group_2, [3, 27])
15 Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
16 geompy.UnionIDs(Group_3, [33, 23])
17 Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
18 geompy.UnionIDs(Group_4, [31, 27])
19 
20 # intersect groups
21 Group_I_1_3 = geompy.IntersectGroups(Group_1, Group_3)
22 Group_IL_1_3 = geompy.IntersectListOfGroups([Group_1, Group_3])
23 
24 # publish shapes
25 geompy.addToStudy(Box_1, 'Box_1')
26 geompy.addToStudyInFather(Box_1, Group_1, 'Group_1')
27 geompy.addToStudyInFather(Box_1, Group_2, 'Group_2')
28 geompy.addToStudyInFather(Box_1, Group_3, 'Group_3')
29 geompy.addToStudyInFather(Box_1, Group_4, 'Group_4')
30 geompy.addToStudyInFather(Box_1, Group_I_1_3, 'Group_I_1_3')
31 geompy.addToStudyInFather(Box_1, Group_IL_1_3, 'Group_IL_1_3')
32 salome.sg.updateObjBrowser(True)

Download this script


Cut Groups

1 # Cut Groups
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 # create a box and some groups of faces on it
10 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
11 Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
12 geompy.UnionIDs(Group_1, [13, 23])
13 Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
14 geompy.UnionIDs(Group_2, [3, 27])
15 Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
16 geompy.UnionIDs(Group_3, [33, 23])
17 Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
18 geompy.UnionIDs(Group_4, [31, 27])
19 
20 # cut groups
21 Group_C_2_4 = geompy.CutGroups(Group_2, Group_4)
22 Group_CL_2_4 = geompy.CutListOfGroups([Group_2], [Group_4])
23 
24 # publish shapes
25 geompy.addToStudy(Box_1, 'Box_1')
26 geompy.addToStudyInFather(Box_1, Group_1, 'Group_1')
27 geompy.addToStudyInFather(Box_1, Group_2, 'Group_2')
28 geompy.addToStudyInFather(Box_1, Group_3, 'Group_3')
29 geompy.addToStudyInFather(Box_1, Group_4, 'Group_4')
30 geompy.addToStudyInFather(Box_1, Group_C_2_4, 'Group_C_2_4')
31 geompy.addToStudyInFather(Box_1, Group_CL_2_4, 'Group_CL_2_4')
32 salome.sg.updateObjBrowser(True)

Download this script