geom/doc/salome/examples/working_with_groups_ex02.py
2021-08-12 08:45:03 +02:00

30 lines
840 B
Python

# Adding an object to the group
import salome
salome.salome_init_without_session()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New()
gg = salome.ImportComponentGUI("GEOM")
# create two vertices
p0 = geompy.MakeVertex(0. , 0. , 0. )
p200 = geompy.MakeVertex(200., 200., 200.)
# create a box from two points
Box = geompy.MakeBoxTwoPnt(p0, p200)
# create a group from the faces of the box
group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
# add objects to the group
SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
for i in [0, 3, 5] :
FaceID = geompy.GetSubShapeID(Box, SubFaceList[i])
geompy.AddObject(group, FaceID)
id_group1 = geompy.addToStudy(group, "Group1")
# display the contents of the group
gg.createAndDisplayGO(id_group1)
salome.sg.updateObjBrowser()