Salome HOME
Synchronize adm files
[modules/geom.git] / doc / salome / examples / boolean_operations_ex02.py
1 # Common
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 a vertex and a vector
11 p1 = geompy.MakeVertex(25, 55, 0)
12 p2 = geompy.MakeVertex( 0,  0, 0)
13 v = geompy.MakeVector(p1, p2)
14
15 # create a cylinder
16 height = 35
17 radius1 = 20
18 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
19
20 # create a sphere
21 sphere = geompy.MakeSphereR(40)
22
23 # create a box
24 box = geompy.MakeBoxDXDYDZ(80, 80, 80)
25
26 # make common
27 common1 = geompy.MakeCommon(cylinder, sphere)
28 common2 = geompy.MakeCommonList([cylinder, sphere, box])
29
30 # add objects in the study
31 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
32 id_sphere = geompy.addToStudy(sphere, "Sphere")
33 id_box = geompy.addToStudy(box, "Box")
34 id_common1 = geompy.addToStudy(common1, "Common_1")
35 id_common2 = geompy.addToStudy(common2, "Common_2")
36
37 # display the results
38 gg.createAndDisplayGO(id_cylinder)
39 gg.setDisplayMode(id_cylinder,1)
40 gg.createAndDisplayGO(id_sphere)
41 gg.setDisplayMode(id_sphere,1)
42 gg.createAndDisplayGO(id_box)
43 gg.setDisplayMode(id_box,1)
44 gg.createAndDisplayGO(id_common1)
45 gg.setDisplayMode(id_common1,1)
46 gg.createAndDisplayGO(id_common2)
47 gg.setDisplayMode(id_common2,1)