Salome HOME
PR: synchro V6_main tag mergeto_V7_main_11Feb13
[modules/geom.git] / doc / salome / examples / basic_geom_objs_ex01.py
1 # Creation of a Point
2
3 import geompy
4 import salome
5 gg = salome.ImportComponentGUI("GEOM")
6
7 # create vertices
8 p0 = geompy.MakeVertex(0., 0., 0.)
9 p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.)
10 px = geompy.MakeVertex(100., 0., 0.)
11 py = geompy.MakeVertex(0., 100., 0.)
12 pz = geompy.MakeVertex(0., 0., 100.)
13 p1 = geompy.MakeVertex(50., 50., 30.)
14
15 # create a curve and vertices on it
16 Arc = geompy.MakeArc(py, pz, px)
17 # create a vertex by parameter
18 p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25)
19 # create a vertex by length
20 p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., None)
21 #create a vertex by point projection
22 p_on_arc3 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10)
23
24 # create 2 lines and make a point on its intersection
25 line_1 = geompy.MakeLineTwoPnt(p0, p100)
26 line_2 = geompy.MakeLineTwoPnt(p1, pz)
27 p_inter = geompy.MakeVertexOnLinesIntersection(line_1, line_2)
28
29 # create a face and vertices on it
30 Add_line = geompy.MakeLineTwoPnt(px, py)
31 arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
32 p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
33 p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35)
34 p_on_face3 = geompy.MakeVertexInsideFace(arc_face)
35
36
37 # add objects in the study
38 id_p0       = geompy.addToStudy(p0,   "Vertex 0")
39 id_p100     = geompy.addToStudy(p100, "Vertex 100")
40 id_px       = geompy.addToStudy(px,   "Vertex X")
41 id_py       = geompy.addToStudy(py,   "Vertex Y")
42 id_pz       = geompy.addToStudy(pz,   "Vertex Z")
43 id_Arc      = geompy.addToStudy(Arc,  "Arc")
44 id_line_1   = geompy.addToStudy(line_1,  "Line 1")
45 id_line_2   = geompy.addToStudy(line_2,  "Line 2")
46 id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc by parameter")
47 id_p_on_arc2  = geompy.addToStudy(p_on_arc2, "Vertex on Arc by length")
48 id_p_on_arc3  = geompy.addToStudy(p_on_arc3, "Vertex on Arc by point projection")
49 id_p_inter    = geompy.addToStudy(p_inter,   "Vertex on Lines Intersection")
50 id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter")
51 id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection")
52 id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside face")
53
54 # display vertices
55 gg.createAndDisplayGO(id_p0)
56 gg.createAndDisplayGO(id_p100)
57 gg.createAndDisplayGO(id_Arc)
58 gg.createAndDisplayGO(id_p_inter)
59 gg.createAndDisplayGO(id_p_on_arc)
60 gg.createAndDisplayGO(id_p_on_arc2)
61 gg.createAndDisplayGO(id_p_on_arc3)