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