Salome HOME
Synchronize adm files
[modules/geom.git] / doc / salome / examples / transformation_operations_ex09.py
1 # Multi Rotation
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 import math
10
11 # create vertices and vectors
12 p0  = geompy.MakeVertex( 0.,  0.,  0.)
13 px  = geompy.MakeVertex(20.,  0.,  0.)
14 py  = geompy.MakeVertex( 0., 20.,  0.)
15 pz  = geompy.MakeVertex( 0.,  0., 20.)
16 pxyz = geompy.MakeVertex( 50., 50., 10.)
17 vz  = geompy.MakeVector(p0, pz)
18 vxy = geompy.MakeVector(px, py)
19 vrot = geompy.MakeVector(p0, pxyz)
20
21 # create an arc
22 arc = geompy.MakeArc(py, pz, px)
23
24 # create a wire
25 wire = geompy.MakeWire([vxy, arc])
26
27 # create a planar face
28 face = geompy.MakeFace(wire, 1)
29
30 # create a prism
31 prism = geompy.MakePrismVecH(face, vz, 20.0)
32
33 # 1. Rotate the prism around the axis vrot 4 times
34
35 # rotation angle = 2 * PI / 4
36 rot1da = geompy.MultiRotate1DNbTimes(prism, vrot, 4)
37
38 # by the given angle of 30 degrees
39 rot1db = geompy.MultiRotate1DByStep(prism, vrot, math.pi/6., 4)
40
41 # 2. Rotate the prism around the axis vrot 4 times
42 #    and translate the result of each rotation 5 times on distance 50
43
44 # rotation angle = 2 * PI / 4
45 rot2da = geompy.MultiRotate2DNbTimes(prism, vrot, 4, 50, 5)
46
47 # by the given angle of 60 degrees
48 rot2db = geompy.MultiRotate2DByStep(prism, vrot, math.pi/3., 4, 50, 5)
49
50 # add objects in the study
51 id_prism = geompy.addToStudy(prism,"Prism")
52 id_rot1da = geompy.addToStudy(rot1da,"Rotation 1D Nb.Times")
53 id_rot1db = geompy.addToStudy(rot1db,"Rotation 1D By Step")
54 id_rot2da = geompy.addToStudy(rot2da,"Rotation 2D Nb.Times")
55 id_rot2db = geompy.addToStudy(rot2db,"Rotation 2D By Step")
56
57 # display the prism and the results of fillet operation
58 gg.createAndDisplayGO(id_prism)
59 gg.setDisplayMode(id_prism,1)
60 gg.createAndDisplayGO(id_rot1da)
61 gg.setDisplayMode(id_rot1da,1)
62 gg.createAndDisplayGO(id_rot1db)
63 gg.setDisplayMode(id_rot1db,1)
64 gg.createAndDisplayGO(id_rot2da)
65 gg.setDisplayMode(id_rot2da,1) 
66 gg.createAndDisplayGO(id_rot2db)
67 gg.setDisplayMode(id_rot2db,1)