Salome HOME
Revert "Synchronize adm files"
[modules/geom.git] / doc / salome / examples / basic_geom_objs_ex04.py
1 # Creation of an Ellipse
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 p1 = geompy.MakeVertex(50., 50., 50.)
13 p2 = geompy.MakeVertex(0., 50., 0.)
14
15 # create a normal vector from two points
16 normal  = geompy.MakeVector(p0, p1)
17
18 # create a major axis vector from two points
19 major   = geompy.MakeVector(p0, p2)
20
21 # create an ellipse from a point, a vector and radiuses
22 ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25)
23
24 # create an ellipse from a point, a normal vector, radiuses and a major axis vector
25 ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major)
26
27 # add objects in the study
28 id_normal   = geompy.addToStudy(normal,   "Normal")
29 id_major    = geompy.addToStudy(major,    "Major Axis")
30 id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1")
31 id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2")
32
33 # display the ellipse and its normal vector
34 gg.createAndDisplayGO(id_normal)
35 gg.createAndDisplayGO(id_major)
36 gg.createAndDisplayGO(id_ellipse1)
37 gg.createAndDisplayGO(id_ellipse2)