Salome HOME
Merge multi-study removal branch.
[modules/geom.git] / doc / salome / examples / boolean_operations_ex03.py
1 # Cut
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
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 #cut
27 cut1 = geompy.MakeCut(cylinder, sphere)
28 cut2 = geompy.MakeCutList(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_cut1 = geompy.addToStudy(cut1, "Cut_1")
35 id_cut2 = geompy.addToStudy(cut2, "Cut_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_cut1)
45 gg.setDisplayMode(id_cut1,1) 
46 gg.createAndDisplayGO(id_cut2)
47 gg.setDisplayMode(id_cut2,1)