Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Boolean Operations


Fuse

1 # Fuse
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 # fuse
27 fuse1 = geompy.MakeFuse(cylinder, sphere)
28 fuse2 = geompy.MakeBoolean(cylinder, sphere, 3)
29 fuse3 = geompy.MakeFuseList([cylinder, sphere, box])
30 
31 # add objects in the study
32 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
33 id_sphere = geompy.addToStudy(sphere, "Sphere")
34 id_box = geompy.addToStudy(box, "Box")
35 id_fuse1 = geompy.addToStudy(fuse1, "Fuse_1")
36 id_fuse2 = geompy.addToStudy(fuse2, "Fuse_2")
37 id_fuse3 = geompy.addToStudy(fuse3, "Fuse_3")
38 
39 # display results
40 gg.createAndDisplayGO(id_cylinder)
41 gg.setDisplayMode(id_cylinder,1)
42 gg.createAndDisplayGO(id_sphere)
43 gg.setDisplayMode(id_sphere,1)
44 gg.createAndDisplayGO(id_box)
45 gg.setDisplayMode(id_box,1)
46 gg.createAndDisplayGO(id_fuse1)
47 gg.setDisplayMode(id_fuse1,1)
48 gg.createAndDisplayGO(id_fuse2)
49 gg.setDisplayMode(id_fuse2,1)
50 gg.createAndDisplayGO(id_fuse3)
51 gg.setDisplayMode(id_fuse3,1)

Download this script


Common

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)

Download this script


Cut

1 # Cut
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 #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)

Download this script


Intersection

1 # Section
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 # make a section
24 section = geompy.MakeSection(cylinder, sphere)
25 
26 # add objects in the study
27 id_section = geompy.addToStudy(section, "Section")
28 
29 # display the results
30 gg.createAndDisplayGO(id_section)
31 gg.setDisplayMode(id_section,1)

Download this script