Salome HOME
bf7d3e87066cb0a69c27bfda6be41eba426b01f7
[modules/geom.git] / doc / salome / examples / basic_geom_objs_ex04.py
1 # Creation of an Ellipse
2
3 import geompy
4 import salome
5 gg = salome.ImportComponentGUI("GEOM")
6
7 # create vertices
8 p0 = geompy.MakeVertex(0., 0., 0.)
9 p1 = geompy.MakeVertex(50., 50., 50.)
10 p2 = geompy.MakeVertex(0., 50., 0.)
11
12 # create a normal vector from two points
13 normal  = geompy.MakeVector(p0, p1)
14
15 # create a major axis vector from two points
16 major   = geompy.MakeVector(p0, p2)
17
18 # create an ellipse from a point, a vector and radiuses
19 ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25)
20
21 # create an ellipse from a point, a normal vector, radiuses and a major axis vector
22 ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major)
23
24 # add objects in the study
25 id_normal   = geompy.addToStudy(normal,   "Normal")
26 id_major    = geompy.addToStudy(major,    "Major Axis")
27 id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1")
28 id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2")
29
30 # display the ellipse and its normal vector
31 gg.createAndDisplayGO(id_normal)
32 gg.createAndDisplayGO(id_major)
33 gg.createAndDisplayGO(id_ellipse1)
34 gg.createAndDisplayGO(id_ellipse2)