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


Creation of a Box

1 # Creation of a Box
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 vertices
11 p0 = geompy.MakeVertex(15, 25, 35)
12 p70 = geompy.MakeVertex(70, 70, 70)
13 
14 # create boxes
15 box1 = geompy.MakeBoxDXDYDZ(10, 20, 30)
16 box2 = geompy.MakeBox(10,20,30, 15,25,35)
17 box3 = geompy.MakeBoxTwoPnt(p0, p70)
18 
19 # add objects in the study
20 id_box1 = geompy.addToStudy(box1,"Box1")
21 id_box2 = geompy.addToStudy(box2,"Box2")
22 id_box3 = geompy.addToStudy(box3,"Box3")
23 
24 # display the boxes
25 gg.createAndDisplayGO(id_box1)
26 gg.setDisplayMode(id_box1,1)
27 gg.createAndDisplayGO(id_box2)
28 gg.setDisplayMode(id_box2,1)
29 gg.createAndDisplayGO(id_box3)
30 gg.setDisplayMode(id_box3,1)

Download this script


Creation of a Cylinder

1 # Creation of a Cylinder
2 
3 import math
4 
5 import salome
6 salome.salome_init()
7 import GEOM
8 from salome.geom import geomBuilder
9 geompy = geomBuilder.New(salome.myStudy)
10 
11 gg = salome.ImportComponentGUI("GEOM")
12 
13 # create a vertex and a vector
14 p1 = geompy.MakeVertex(25, 35, 45)
15 p2 = geompy.MakeVertex(70, 70, 70)
16 v = geompy.MakeVector(p1, p2)
17 
18 # create cylinders
19 height = 40
20 radius1 = 15
21 radius2 = 30
22 angle1 = 45. * math.pi / 180.
23 angle2 = 210. * math.pi / 180.
24 
25 cylinder1 = geompy.MakeCylinder(p1, v, radius1, height)
26 
27 cylinder2 = geompy.MakeCylinderRH(radius2, height)
28 
29 cylinder3 = geompy.MakeCylinderA(p1, v, radius1, height, angle1)
30 geompy.TranslateDXDYDZ(cylinder3, 80., 0., 0.)
31 
32 cylinder4 = geompy.MakeCylinderRHA(radius2, height, angle2)
33 geompy.TranslateDXDYDZ(cylinder4, 80., 0., 0.)
34 
35 # add objects in the study
36 id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1")
37 id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2")
38 id_cylinder3 = geompy.addToStudy(cylinder3,"Cylinder3")
39 id_cylinder4 = geompy.addToStudy(cylinder4,"Cylinder4")
40 
41 # display the cylinders
42 gg.createAndDisplayGO(id_cylinder1)
43 gg.setDisplayMode(id_cylinder1,1)
44 gg.createAndDisplayGO(id_cylinder2)
45 gg.setDisplayMode(id_cylinder2,1)
46 gg.createAndDisplayGO(id_cylinder3)
47 gg.setDisplayMode(id_cylinder3,1)
48 gg.createAndDisplayGO(id_cylinder4)
49 gg.setDisplayMode(id_cylinder4,1)

Download this script


Creation of a Sphere

1 # Creation of a Sphere
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
11 p = geompy.MakeVertex(55, 45, 25)
12 
13 # create spheres
14 radius1 = 20
15 sphere1 = geompy.MakeSpherePntR(p, radius1)
16 radius2 = 15
17 sphere2 = geompy.MakeSphere(0, 0, 45, radius2)
18 radius3 = 30
19 sphere3 = geompy.MakeSphereR(radius3)
20 
21 # add objects in the study
22 id_sphere1 = geompy.addToStudy(sphere1,"Sphere1")
23 id_sphere2 = geompy.addToStudy(sphere2,"Sphere2")
24 id_sphere3 = geompy.addToStudy(sphere3,"Sphere3")
25 
26 # display spheres
27 gg.createAndDisplayGO(id_sphere1)
28 gg.setDisplayMode(id_sphere1,1)
29 gg.createAndDisplayGO(id_sphere2)
30 gg.setDisplayMode(id_sphere2,1)
31 gg.createAndDisplayGO(id_sphere3)
32 gg.setDisplayMode(id_sphere3,1)

Download this script


Creation of a Torus

1 # Creation of a Torus
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(35, 40, 45)
12 p2 = geompy.MakeVertex(35, 45, 70)
13 v = geompy.MakeVector(p1, p2)
14 
15 # create toruses
16 torus1 = geompy.MakeTorus(p1, v, 20, 10)
17 torus2 = geompy.MakeTorusRR(30, 15)
18 
19 # add objects in the study
20 id_torus1 = geompy.addToStudy(torus1,"Torus1")
21 id_torus2 = geompy.addToStudy(torus2,"Torus2")
22 
23 # display toruses
24 gg.createAndDisplayGO(id_torus1)
25 gg.setDisplayMode(id_torus1,1)
26 gg.createAndDisplayGO(id_torus2)
27 gg.setDisplayMode(id_torus2,1)

Download this script


Creation of a Cone

1 # Creation of a Cone
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(35, 35, 0)
12 p2 = geompy.MakeVertex(35, 35, 70)
13 v = geompy.MakeVector(p1, p2)
14 
15 # create cones
16 cone1 = geompy.MakeCone(p1, v, 17, 1, 20)
17 cone2 = geompy.MakeConeR1R2H(30, 10, 30)
18 
19 # add objects in the study
20 id_cone1 = geompy.addToStudy(cone1,"Cone1")
21 id_cone2 = geompy.addToStudy(cone2,"Cone2")
22 
23 # display cones
24 gg.createAndDisplayGO(id_cone1)
25 gg.setDisplayMode(id_cone1,1)
26 gg.createAndDisplayGO(id_cone2)
27 gg.setDisplayMode(id_cone2,1)

Download this script


Creation of a Disk

1 # Creation of a Disk
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 vertices
11 p0 = geompy.MakeVertex(0., 0., 0.)
12 px = geompy.MakeVertex(100., 0. , 0. )
13 py = geompy.MakeVertex(0. , 100., 0. )
14 pz = geompy.MakeVertex(0. , 0. , 100.)
15 
16 # create a vector on two points
17 vxy = geompy.MakeVector(px, py)
18 
19 # create a disk in OXY plane
20 disk1 = geompy.MakeDiskR(100, 1)
21 
22 # create a disk from a point, a vector and a radius
23 disk2 = geompy.MakeDiskPntVecR(pz, vxy, 30)
24 
25 #create a circle from three points
26 disk3 = geompy.MakeDiskThreePnt(p0, px, py)
27 
28 # add objects in the study
29 id_vxy = geompy.addToStudy(vxy, "Vector")
30 id_disk1 = geompy.addToStudy(disk1,"Disk1")
31 id_disk2 = geompy.addToStudy(disk2,"Disk2")
32 id_disk3 = geompy.addToStudy(disk3,"Disk3")
33 
34 # display disks
35 gg.createAndDisplayGO(id_vxy)
36 gg.createAndDisplayGO(id_disk1)
37 gg.createAndDisplayGO(id_disk2)
38 gg.createAndDisplayGO(id_disk3)

Download this script


Creation of a Rectangle

1 # Creation of a Rectangle
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 vertices
11 px = geompy.MakeVertex(100., 0. , 0. )
12 py = geompy.MakeVertex(0. , 100., 0. )
13 
14 # create a vector on two points
15 vxy = geompy.MakeVector(px, py)
16 
17 # create a rectangle in OXY plane
18 face1 = geompy.MakeFaceHW(100, 100, 1)
19 
20 # create a rectangle using normal vector
21 face2 = geompy.MakeFaceObjHW(vxy, 50, 150)
22 
23 # create a rectangle from other face
24 face3 = geompy.MakeFaceObjHW(face2, 150, 50)
25 
26 # add objects in the study
27 id_face1 = geompy.addToStudy(face1,"Face1")
28 id_face2 = geompy.addToStudy(face2,"Face2")
29 id_face3 = geompy.addToStudy(face3,"Face3")
30 
31 # display rectangles
32 gg.createAndDisplayGO(id_face1)
33 gg.createAndDisplayGO(id_face2)
34 gg.createAndDisplayGO(id_face3)

Download this script