Salome HOME
b3933912e5d4529c5040ea924d84f9b412b9c4cb
[modules/shaper.git] / test.API / SHAPER / Transformations / TestAPI_Translation.py
1 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 # File:        TestAPI_Translation.py
4 # Created:     15 Nov 2016
5 # Author:      Clarisse Genrault (CEA)
6
7 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
8 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
9 from GeomAPI import GeomAPI_Ax1 as axis
10 from GeomAPI import GeomAPI_Pnt as pnt
11 from GeomAPI import GeomAPI_Dir as direction
12
13 # Create a box
14 try :
15   box = shaperpy.makeBox(10.,10.,10.)
16  
17 except myExcept, ec:
18   print ec.what()
19
20 # Perfom a translation with an axis and a distance.
21 try :
22   origin = pnt(0.,0.,0.)
23   xDir = direction(1.,0.,0.)
24   xAxis = axis(origin, xDir)
25   translation1 = shaperpy.makeTranslation(box,xAxis,15.)
26  
27 except myExcept, ec:
28   print ec.what()
29
30 # Perfom a translation with dimensions.
31 try :
32   translation2 = shaperpy.makeTranslation(box,10,0,0)
33  
34 except myExcept, ec:
35   print ec.what()
36
37 # Perfom a translation with two points.
38 try :
39   pnt1 = pnt(10.,0.,0.)
40   pnt2 = pnt(10.,15.,0.)
41   translation3 = shaperpy.makeTranslation(box,pnt1,pnt2)
42  
43 except myExcept, ec:
44   print ec.what()